I am trying to add an external folder, setup/
, to my Jetty's classpath. I can successfully add the setup
folder to its classpath inside of its launch configurations
in eclipse. I need to instead give it the setup
folder's path as an argument to Jetty because I don't have control of the launch configurations
when I run my project outside of an eclipse environment. I've tried stuff like this in the XML:
<jvmarg value="-Dpath=${DbServer.location}/setup"/>
This does not do anything... Any help is appreciated, thanks!
The issue is that the setup folder is in the WAR directory, so even pointing to anything else as the classpath will not make changes to where Jetty will look for the folder. Look here for how Jetty uses its classpath:
Classes contained within
WEB-INF/lib
orWEB-INF/classes
have priority over classes on the parent class loader. This is the opposite of the normal behaviour of a java 2 class loader.
As an example, to run it with the help of Maven ( jetty-maven-plugin ) :
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.7.v20170914</version>
<configuration>
<httpConnector>
<port>8095</port>
</httpConnector>
<webApp>
<contextPath>/</contextPath>
<extraClasspath>conf/</extraClasspath>
</webApp>
</configuration>
</plugin>
Then run your webapp with mvn jetty:run
At the root of my project, I have a ./conf/
directory, including some properties or xml files.
Some configuration properties for can be found at Configuring Your WebApp , but you can find undocumented properties in the class org.eclipse.jetty.webapp.WebAppContext
or in org.eclipse.jetty.maven.plugin.JettyWebAppContext
(its subclass).
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.