我用碼頭,Maven的插件具有以下配置:碼頭預警與Maven插件「沒有上下文resourceBase或戰爭集」
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.1.v20170120</version>
<configuration>
<jettyConfig>${basedir}/src/main/webapp/WEB-INF/development.jetty-config.xml</jettyConfig>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
<contextPath>/</contextPath>
</contextHandler>
</contextHandlers>
<reload>manual</reload>
<scanIntervalSeconds>0</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
</webApp>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
</dependencies>
</plugin>
文件development.jetty-config.xml
有以下內容:
<?xml version="1.0"?>
<Configure class="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
<Set name="resourceBase">./src/main/webapp</Set>
<Set name="contextPath">/</Set>
<Set name="war"><Property name="jetty.home" default="." />./src/main/webapp</Set>
<New id="proj1DS" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/proj1</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://localhost/mydb</Set>
<Set name="User">root</Set>
<Set name="Password">***</Set>
<Set name="UseUnicode">true</Set>
<Set name="CharacterEncoding">UTF-8</Set>
</New>
</Arg>
</New>
</Configure>
然後我和一個Maven命令啓動碼頭:
mvn jetty:run
相關插件日誌:
[INFO] <<< jetty-maven-plugin:9.4.1.v20170120:run (default-cli) < test-compile @ proj1-admin <<<
[INFO]
[INFO] --- jetty-maven-plugin:9.4.1.v20170120:run (default-cli) @ proj1-admin ---
2017-02-22 11:41:42.311:INFO::main: Logging initialized @3350ms to org.eclipse.jetty.util.log.StdErrLog
[INFO] Configuring Jetty for project: Proj Admin
[INFO] webAppSourceDirectory not set. Trying src/main/webapp
[INFO] Reload Mechanic: manual
[INFO] Classes = /home/igor/projects/Proj1/admin/target/classes
[INFO] Configuring Jetty from xml configuration file = /home/igor/projects/proj1/admin/src/main/webapp/WEB-INF/development.jetty-config.xml
[INFO] Context path =/
[INFO] Tmp directory = /home/igor/projects/proj1/admin/target/tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:///home/igor/projects/proj1/admin/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = /home/igor/projects/proj1/admin/src/main/webapp
2017-02-22 11:41:42.449:INFO:oejs.Server:main: jetty-9.4.1.v20170120
2017-02-22 11:41:44.694:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=1975ms
2017-02-22 11:41:44.904:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2017-02-22 11:41:44.904:INFO:oejs.session:main: No SessionScavenger set, using defaults
2017-02-22 11:41:44.907:INFO:oejs.session:main: Scavenging every 600000ms
然後打印這樣的警告:
2017-02-22 11:41:47.150:INFO:oejsh.ContextHandler:main: Started [email protected]{/,file:///home/igor/projects/proj1/admin/src/main/webapp/,AVAILABLE}{file:///home/igor/projects/proj1/admin/src/main/webapp/}
2017-02-22 11:41:47.154:WARN:oejw.WebInfConfiguration:main: Can't generate resourceBase as part of webapp tmp dir name: java.lang.IllegalStateException: No resourceBase or war set for context
2017-02-22 11:41:47.155:WARN:oejw.WebAppContext:main: Failed startup of context [email protected]{/,null,null}
java.lang.IllegalStateException: No resourceBase or war set for context
at org.eclipse.jetty.webapp.WebInfConfiguration.unpack(WebInfConfiguration.java:406)
at org.eclipse.jetty.maven.plugin.MavenWebInfConfiguration.unpack(MavenWebInfConfiguration.java:135)
at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:72)
at org.eclipse.jetty.maven.plugin.MavenWebInfConfiguration.preConfigure(MavenWebInfConfiguration.java:95)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:501)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:539)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:432)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.server.Server.start(Server.java:452)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:419)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:460)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:328)
at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:170)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
要我surprize,加載應用程序和workig正常。此外,三線配置文件:
<Set name="resourceBase">./src/main/webapp</Set>
<Set name="contextPath">/</Set>
<Set name="war"><Property name="jetty.home" default="."/>./src/main/webapp</Set>
沒有任何影響,即使我刪除它們。
我看了看文檔,而這些答案,但無法弄清楚:
How to deploy my web application to jetty9 as root application?
No hot deployment in Jetty 9.0.6
Jetty config without resourceBase
我的問題是:
- 如何正確配置這個插件來擺脫警告?
- 我應該真的擔心,因爲這不是一個錯誤,應用程序正在工作?
我也跟着你的建議和我的聚甲醛去除這樣的: <的ContextHandlers> \t \t \t / contextPath> \t contextHandler> \t contextHandlers> 警告現在消失了。非常感謝您的幫助! –
ipolevoy