Java 如何根据环境在web.xml中设置值
我正在使用Sprint3.1概要文件,在我的web.xml中有以下代码Java 如何根据环境在web.xml中设置值,java,spring-mvc,tomcat7,spring-3,Java,Spring Mvc,Tomcat7,Spring 3,我正在使用Sprint3.1概要文件,在我的web.xml中有以下代码 <context-param> <param-name>spring.profiles.active</param-name> <param-value>dev</param-value> </context-param> spring.profiles.active 发展 为了部署到测试环境,我的工作流当前要求我将属性值更改为t
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</context-param>
spring.profiles.active
发展
为了部署到测试环境,我的工作流当前要求我将属性值更改为test
,然后制作一个jar并部署它。但是,我希望与明确地进行此更改分离
我希望工作流只是构建war并将其部署到测试中。测试环境应该有一些变量将spring.profiles.active
变量设置为test
问题
如何在tomcat7中设置变量spring.profiles.active,并配置
web.xml
,以便它从服务器配置中读取变量?使用Tomcat中的环境标记。然后在代码中,使用上下文的查找方法
编辑:示例(参见问题):
hmm我知道如何在tomcat中设置变量。但是如何从web.xml访问它呢?我是否需要特别创建applicationConfiguration类来设置此变量,或者是否有方法直接从web.xml本身进行设置。