【发布时间】:2015-03-11 11:40:31
【问题描述】:
如何设置活动弹簧配置文件或 tomcat maven 插件?我想在运行时从环境中获取活动配置文件,但我总是得到空数组。
我尝试在 pom.xml 的插件配置中添加这个 systemProperties:
<JAVA_OPTS>-Dspring.profiles.active=local</JAVA_OPTS>
或
<name>spring.profiles.active</name>
<value>locale</value>
我尝试在 context.xml 中添加这个:
<environment name="spring.profiles.active" value="local" type="java.lang.String" override="false"/>
但仍然没有活跃的个人资料...
我的环境:Java 6、tomcat7-maven-plugin 2.2 版、Netbeans 8.0.2、Spring 3.1.1.RELEASE。
我的 pom.xml tomcat 插件看起来是这样的:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- http port -->
<port>8084</port>
<contextFile>${basedir}/src/main/resources-local/context.xml</contextFile>
<systemProperties>
<JAVA_OPTS>-Dspring.profiles.active=local</JAVA_OPTS>
</systemProperties>
</configuration>
<executions>
<execution>
<id>tomcat-run</id>
<goals>
<goal>run-war</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<dependencies>
【问题讨论】:
标签: spring maven-tomcat-plugin