Tomcat - 如何指定可以在 server.xml 中扩展的属性

标签 tomcat configuration properties server.xml

目前,我的 server.xml 中有:

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />

我希望它变成:

<Connector port="${oms.ui.port}" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />

我将此属性 oms.ui.port 放在驻留在 apache-tomcat-7.0.8\lib 中的属性文件中 但它没有找到它,我得到:

WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'port' to '${oms.ui.port}' did not find a matching property.

也许有更好的 Tomcat 经验的人可以帮助我,好吗?

最佳答案

根据 Tomcat 7.0 Configuration Overview :

Apache Ant-style variable substitution is supported; a system property with the name propname may be used in a configuration file using the syntax ${propname}. All system properties are available including those set using the -D syntax, those automatically made available by the JVM and those configured in the $CATALINA_BASE/conf/catalina.properties file.

因此,您可以使用 JVM 系统属性或 catalina.properties 来声明您的变量并为其赋值。

关于Tomcat - 如何指定可以在 server.xml 中扩展的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8254543/

相关文章:

java - WEB-INF/lib 目录与 Java 9 模块

c# - .net 路由开头的可选参数

c# - ViewModel 中的可绑定(bind)字段

java - 如何在apache tomcat中配置域名

apache - 日文字母在我的页面中显示不正确

java - 我的 ajax POST 没有发送到我的 servlet

.net - 如何让企业库配置和项目设置设计器在app.config中引用相同的值

configuration - Windows : Fatal configuration error 上的 Cassandra

javascript - 如何 "concatinate"属性

java - 在不使用 java.util.Properties 的情况下读取文件并获取 key=value