[英]How can I configure my tomcat application using server.xml?
I've got a webapp that is deployed in Tomcat. 我有一个部署在Tomcat中的webapp。
The webapp uses a db.properties
file to resolve dataSource
bean properties in applicationContext.xml
: db.properties
应用程序使用db.properties
文件来解析applicationContext.xml
dataSource
bean属性:
<context:property-placeholder location="file:${catalina.home}/conf/db.properties"/>
In this example db.properties
file is placed in common /conf/
directory of the Tomcat. 在此示例中,
db.properties
文件位于Tomcat的common /conf/
目录中。
And I want to place it not in common /conf/
, but in a separate subdirectory, like /conf/myapp/
, and myapp
should be configured not in application sources, but in Tomcat settings, like server.xml
. 而且我不想将其放置在公共
/conf/
,而是放置在单独的子目录中,例如/conf/myapp/
,并且myapp
不应配置在应用程序源中,而应配置在Tomcat设置中,例如server.xml
。
I need it to deploy two copies of this webapp, but they should work with different databases. 我需要它来部署此Web应用程序的两个副本,但它们应与其他数据库一起使用。
How can I do this? 我怎样才能做到这一点?
UPDATE 更新
Here's my service
block from server.xml
这是我来自
server.xml
service
块
<Service name="train">
<Connector port="8888" protocol="HTTP/1.1" connectionTimeout="20000" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,text/json,application/x-javascript,application/javascript,application/json"/>
<Engine name="trainings" defaultHost="localhost">
<Host name="localhost" appBase="webapps">
<Context docBase="trs" path="" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/train/int" prefix="access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<context:property-placeholder/>
in applicationContext.xml <context:property-placeholder/>
放置在applicationContext.xml中 <Environment name="db.host" value="localhost" type="java.lang.String" override="false"/>
in server.xml in Context
section Context
部分中server.xml中的<Environment name="db.host" value="localhost" type="java.lang.String" override="false"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.