在Jetty和Tomcat中运行Web应用程序 [英] Running web app in both Jetty and Tomcat
问题描述
我有一个Web应用程序,在生产中我在Tomcat上运行.它使用MySQL连接器,但是并没有与战争捆绑在一起,而是包含在Tomcat的公共lib目录下,以便我可以通过JNDI访问数据源.
I have a web app which in production I run on Tomcat. It uses the MySQL connector, however it is not bundled up with the war, rather it is included under Tomcat's common lib directory, so that I can access the data source through JNDI.
我想在开发过程中与Jetty做类似的事情,更确切地说是与Jetty + Maven做类似的事情.通过Maven运行Jetty时,是否有办法在类路径中包含mysql-connector jar(即,未将其捆绑在war文件中)?
I would like to do something similar with Jetty (while developing), and more precisely Jetty + Maven. Is there a way for me to include the mysql-connector jar in the classpath when running Jetty through Maven (i.e. not have it bundled in the war file)?
我还应该注意,我在构建过程中使用了Maven,并将mysql-connector指定为提供的"范围.
Also I should note that I am using Maven for my build process and have the mysql-connector specified as "provided" scope.
推荐答案
此外,上一个答案: 您必须在maven config依赖项中添加到您的jetty插件:
Additinally to previous answer: you have to add to your jetty plugin in maven config dependency:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<stopKey>blah-blah-blah</stopKey>
<stopPort>9966</stopPort>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
<jettyEnvXml>${basedir}/src/jetty-env.xml</jettyEnvXml>
</configuration>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-701.jdbc4</version>
</dependency>
</dependencies>
</plugin>
然后您可以在主要项目依赖项中使用提供的范围.我现在就做到了,而且行得通.谢谢您的问题(还有Nishant)
And then you can use provided scope at main project dependencies. I did it right now, and it works. Thank you for your question (and Nishant too)
这篇关于在Jetty和Tomcat中运行Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!