參考:Jetty使用教程(一)——開始使用Jettyhtml
參考上面文檔,可是有些更新:java
echo $JETTY_HOME /Users/aliyun/Downloads/softwoare/jetty-distribution-9.4.7.v20170914 ali-2cf0ee28bc54:jetty aliyun$ java -jar $JETTY_HOME/start.jar ERROR : Nothing to start, exiting ... Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs] java -jar $JETTY_HOME/start.jar --help # for more information ali-2cf0ee28bc54:jetty aliyun$ pwd /Users/aliyun/code/web/jetty ali-2cf0ee28bc54:jetty aliyun$ JETTY_BASE=/Users/aliyun/code/web/jetty/ ali-2cf0ee28bc54:jetty aliyun$ java -jar $JETTY_HOME/start.jar ERROR : Nothing to start, exiting ... Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs] java -jar $JETTY_HOME/start.jar --help # for more information ali-2cf0ee28bc54:jetty aliyun$ java -jar $JETTY_HOME/start.jar --add-to-startd=http,deploy WARN : --add-to-startd is deprecated! Instead use: --create-startd --add-to-start=http,deploy MKDIR : ${jetty.base}/start.d INFO : webapp transitively enabled, ini template available with --add-to-start=webapp INFO : server transitively enabled, ini template available with --add-to-start=server INFO : security transitively enabled INFO : servlet transitively enabled INFO : http initialized in ${jetty.base}/start.d/http.ini INFO : deploy initialized in ${jetty.base}/start.d/deploy.ini MKDIR : ${jetty.base}/webapps INFO : Base directory was modified ali-2cf0ee28bc54:jetty aliyun$ 建議使用: Instead use: --create-startd --add-to-start=http,deploy
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/nio/SelectChannelConnector
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getStatus()I
+- org.apache.velocity:velocity-tools:jar:2.0:provided [INFO] | +- commons-beanutils:commons-beanutils:jar:1.7.0:provided [INFO] | +- commons-digester:commons-digester:jar:1.8:provided [INFO] | +- commons-chain:commons-chain:jar:1.1:provided [INFO] | +- commons-logging:commons-logging:jar:1.1:provided [INFO] | | \- javax.servlet:servlet-api:jar:2.3:provided [INFO] | +- commons-validator:commons-validator:jar:1.3.1:provided <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-tools</artifactId> <version>2.0</version> <scope>provided</scope> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> </exclusions> </dependency>
ali-2cf0ee28bc54:jfinal-web-1.0.0-RELEASE aliyun$ java -cp WEB-INF/lib/*:WEB-INF/classes/ top.hunaner.JfinalApplication Starting JFinal 3.3 2017-12-20 17:02:16.036:INFO::main: Logging initialized @293ms Starting scanner at interval of 5 seconds. Starting web server on port: 8006 2017-12-20 17:02:16.197:INFO:oejs.Server:main: jetty-9.2.7.v20150116 2017-12-20 17:02:16.462:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet 2017-12-20 17:02:16.607:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@59494225{/,file:/Users/aliyun/Documents/GitHub/hello-world/code/jfinal/project/jfinalTest/target/jfinal-web-1.0.0-RELEASE/,AVAILABLE} //注意這裏說明了jfinal項目的地址,與單獨使用jetty一致。 2017-12-20 17:02:16.641:INFO:oejs.ServerConnector:main: Started ServerConnector@55b9ae50{HTTP/1.1}{0.0.0.0:8006} 2017-12-20 17:02:16.642:INFO:oejs.Server:main: Started @901ms Starting Complete. Welcome To The JFinal World :) Before method invoking After method invoking JFinal action report -------- 2017-12-20 17:02:28 ------------------------------ Url : GET /hello Controller : top.hunaner.controller.HelloController.(HelloController.java:1) Method : index Interceptor : top.hunaner.interceptor.LogInterceptor.(LogInterceptor.java:1) --------------------------------------------------------------------------------