提问者:小点点

如何使用server.xml?配置我的tomcat应用程序


我有一个部署在Tomcat中的webapp。

webapp使用< code>db.properties文件来解析< code > application context . XML 中的< code>dataSource bean属性:

<context:property-placeholder location="file:${catalina.home}/conf/db.properties"/>

在此示例中,db.properties 文件放置在 Tomcat 的公共 /conf/ 目录中。

我不想把它放在公共的/conf/,而是放在一个单独的子目录中,比如/conf/myapp/,并且myapp不应该在应用程序源代码中配置,而应该在Tomcat设置中配置,比如server.xml

我需要它来部署这个webapp的两个副本,但它们应该与不同的数据库一起工作。

我该怎么做?

更新

这是我的服务来自server.xml

<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 &quot;%r&quot; %s %b" />
        </Host>
    </Engine>
</Service>

共1个答案

匿名用户

  1. 放置<代码>