maven tomcat plugin with mysql driver in $catalina_home/lib

百般思念 提交于 2019-12-12 08:36:26

问题


i am trying to use a container managed datasource (via context.xml) in tomcat. The corresponding jar file needs to go in $catalina_home/lib, otherwise tomcat can't find it. (not in webapp/WEB-INF/lib, because it is managed by the webserver, not by the application itself)

the problem is: I am using maven with the maven-tomcat-plugin, so I don't have a $catalina_home (everything is distributed in my .m2 -repository).

So the question is: how can I add the mysql driver jar to the classpath of the tomcat server (mvn tomcat:run)?

thanks a lot,

gerolf.


回答1:


Did you try to add the JDBC driver as a dependency of the maven-tomcat-plugin:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
      ...
    </configuration>
    <dependencies>
      <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.0.5</version>
      </dependency>
    </dependencies>        
  </plugin>


来源:https://stackoverflow.com/questions/2273109/maven-tomcat-plugin-with-mysql-driver-in-catalina-home-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!