2016-08-21 70 views
0

我已經得到了部署在Tomcat的web應用程序。如何使用server.xml配置我的tomcat應用程序?

該web應用使用db.properties文件中applicationContext.xml解決dataSource bean屬性:

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

在這個例子中db.properties文件放置在共同/conf/目錄的Tomcat。

而且我想不把它放在共同/conf/,但在一個單獨的子目錄,像/conf/myapp/,並myapp應不應用源配置,但在Tomcat的設置,比如server.xml

我需要它來部署這個Web應用程序的兩個副本,但他們應該有不同的數據庫。

我該怎麼做?

UPDATE

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

回答

0
  1. 地方<context:property-placeholder/>在applicationContext.xml中
  2. 在server.xml中
  3. <Environment name="db.host" value="localhost" type="java.lang.String" override="false"/>Context部分
  4. 只需使用$ { db.host}中的應用程序通貨膨脹。
相關問題