How to specify spring.profiles.active when running mvn install

In this web application with Spring, I created several application properties files for different deployment environments. They define different db connection configurations.

application-dev.properties
application-qa.properties
application-stg.properties
application-prod.properties

The recommended method according to spring doc is to set spring.profiles.active as a JVM option at runtime, for example:

-Dspring.profiles.active=prod

However, what should I do to deploy the application as a warfare using the mvn installation. How to set up spring profile? I am using Eclipse.

EDIT : I set the JVM option to start configuration. It doesn't seem like maven picks it up when I deploy it like a war, though, since I got the following error from tomcat:

Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception
+4
1

Run- > run configurations maven, JRE VM.

+3

Source: https://habr.com/ru/post/1652072/


All Articles