简体   繁体   中英

How to migrate a tomcat webapp to jetty

I have the following host entry in my server.xml for tomcat

<Host name="app.andrewbucknell.com" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
  <Context path="" docBase="app" debug="5"/>
  <Valve className="org.apache.catalina.valves.AccessLogValve"
         prefix="app_access_log." suffix=".txt"
         pattern="common"/>
  <Resource name="jdbc/appDB" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="appuser" password="apppass" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/appDB"/>
</Host>

I am trying to move to Jetty but cant figure out where to put the resource declaration.

What I want is for the resource declaration to wind up being server specific rather than app specific. Any suggestions?

Not an expert of jetty, but from their documentation page you could achieve what you want by creating a jetty.xml or WEB-INF/jetty-env.xml file and define the datasource in it as follows:

<New id="jdbc/appDB" class="org.eclipse.jetty.plus.jndi.Resource">
 <Arg></Arg>
 <Arg>jdbc/appDB</Arg>
 <Arg>
    <New class="com.mysql.jdbc.Driver">
       <Set name="Url">jdbc:mysql://localhost:3306/appDB</Set>
       <Set name="User">appuser</Set>
       <Set name="Password">apppass</Set>
    </New>
 </Arg>
</New>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM