当我运行mvn安装时如何指定spring.profiles.active [英] How to specify spring.profiles.active when I run mvn install
问题描述
在使用Spring的Web应用程序中,我为不同的部署环境创建了多个应用程序属性文件。它们指定不同的db连接配置。
application-dev.properties
application-qa.properties
application-stg.properties
application-prod.properties
根据。当我将其部署为战争时,似乎没有被拾取,因为我从tomcat中收到以下错误:
无法实例化[javax.sql.DataSource]:Factory方法'dataSource'抛出异常
在Run->运行配置下,选择您的maven启动配置,然后选择JRE选项卡,然后在VM参数文本区域中键入参数。
In this web application with Spring, I created several application-property files for different deploy environment. They specify different db connection configs.
application-dev.properties
application-qa.properties
application-stg.properties
application-prod.properties
The recommended way according to spring doc is to set spring.profiles.active as JVM option at run time, for example:
-Dspring.profiles.active=prod
However what should I do for deploying the application as war using mvn install. How should I set the spring profile? I am using Eclipse.
EDIT: I set the JVM option under . It does not seem to get picked up by maven when I deploy it as a war though since I got the following error from tomcat:
Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception
Under Run->run configurations, select your maven launch configuration, then select the JRE tab, and type your argument in the VM arguments text area.
这篇关于当我运行mvn安装时如何指定spring.profiles.active的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!