0
我是新的碼頭。碼頭 - 澤西島和罐子問題
我總是在Tomcat上工作,但對於這個項目我需要使用嵌入式碼頭服務器。
我的項目結構爲:
src
package
controller
main
...
WebContent
META-INF
WEB-INF
lib
web.xml
我創建了一個主內package.main這樣的:
public class ServerLauncher {
public static void main(String[] args) throws Exception
{
new ServerLauncher().configureServer();
}
public void configureServer() throws Exception{
Server server = new Server(8080);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar("WebContent");
server.setHandler(webapp);
server.start();
server.join();
}
}
我的問題是:
,當我從Eclipse中執行它,它正確的作品。
當我導出RunnableJar文件,它沒有找到我網絡內容:
SLF4J: This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version
- Logging initialized @248ms
- jetty-9.3.z-SNAPSHOT
- Web application not found WebContent
- Failed startup of context [email protected]{/,null,null}{WebContent}
java.io.FileNotFoundException: WebContent
at org.eclipse.jetty.webapp.WebInfConfiguration.unpack(WebInfConfiguration.java:493)
at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:72)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:460)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:496)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:388)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:355)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at package.main.ServerLauncher.main(ServerLauncher.java:19)
- Started [email protected]{HTTP/1.1}{0.0.0.0:8080}
- Started @462ms
我怎樣才能正確導出罐子,以便正確地執行罈子?
謝謝!