0

With IntelliJ, I can specify a Spring boot profile to run when starting a service enter image description here

However, if I run mvn clean install, then the tests are run with the default profile, which causes them to fail. How can I tell mvn to run the tests with a specific Spring Boot profile?

4
  • stackoverflow.com/questions/42390860/… Commented Jun 27, 2022 at 20:51
  • @BarbetNL using Maven profiles is the wrong way. Commented Jun 27, 2022 at 21:18
  • 1
    You have to define the profiles in your tests or even better use the appropriate application.properteis in src/test/resources for all tests or define them at the appropriate tests (docs.spring.io/spring-boot/docs/2.7.1/reference/htmlsingle/…) Commented Jun 27, 2022 at 21:21
  • There are some other suggestions in that link I posted. There are many ways to do this. Peter's question is how to do it in command-line: mvn spring-boot:run -Dspring.profiles.active={profile_name} Commented Jun 28, 2022 at 7:39

1 Answer 1

2

Create/define a properties file and put it within your src/test/resources folder.

Use class level annotation @ActiveProfiles and specify your property file name like this @ActiveProfiles("myProperties")

Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.