Maven配置Web容器

Maven项目使用内嵌容器

  • tomcat7

启动命令:tomcat:run

  1. <build>
  2. <finalName>demo</finalName>
  3. <pluginManagement>
  4. <plugins>
  5. <plugin>
  6. <groupId>org.apache.tomcat.maven</groupId>
  7. <artifactId>tomcat7-maven-plugin</artifactId>
  8. <version>2.1</version>
  9. <configuration>
  10. <port>8080</port>
  11. <path>/demo</path>
  12. <uriEncoding>UTF-8</uriEncoding>
  13. <finalName>web</finalName>
  14. <server>tomcat7</server>
  15. </configuration>
  16. </plugin>
  17. </plugins>
  18. </pluginManagement>
  19. </build>
  • tomcat6

注意tomcat6使用jdk范围为jdk1.6-jdk1.7,若为jdk1.8+则会报如下错误

  1. 严重: Compilation error
  2. org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
  3. at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:342)
  4. at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:206)
  5. at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:163)
  6. at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:96)
  7. at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
  8. at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:97)
  9. at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:167)
  10. at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2187)
  11. at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:974)
  12. at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1164)
  13. at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:366)
  14. at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:623)
  15. at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:392)
  16. at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:429)
  17. at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
  18. at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
  19. at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
  20. at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
  21. at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
  22. at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
  23. at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
  24. at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  25. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  26. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  27. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  28. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  29. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  30. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  31. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  32. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
  33. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
  34. at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
  35. at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  36. at java.lang.Thread.run(Thread.java:748)
  37. 六月 13, 2019 8:54:57 下午 org.apache.catalina.core.StandardWrapperValve invoke
  38. 严重: Servlet.service() for servlet jsp threw exception
  39. org.apache.jasper.JasperException: Unable to compile class for JSP:
  40. An error occurred at line: 1 in the generated java file
  41. The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files
  42. Stacktrace:
  43. at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
  44. at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
  45. at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
  46. at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
  47. at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
  48. at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
  49. at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
  50. at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
  51. at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
  52. at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
  53. at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  54. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  55. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  56. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  57. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  58. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  59. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  60. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  61. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
  62. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
  63. at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
  64. at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  65. at java.lang.Thread.run(Thread.java:748)
  • tomcat6配置

启动命令:tomcat:run

  1. <build>
  2. <finalName>demo</finalName>
  3. <pluginManagement>
  4. <plugins>
  5. <plugin>
  6. <groupId>org.apache.tomcat.maven</groupId>
  7. <artifactId>tomcat6-maven-plugin</artifactId>
  8. <version>2.0</version>
  9. <configuration>
  10. <port>80</port>
  11. <path>/demo</path>
  12. <uriEncoding>UTF-8</uriEncoding>
  13. <finalName>web</finalName>
  14. <server>tomcat</server>
  15. </configuration>
  16. </plugin>
  17. </plugins>
  18. </pluginManagement>
  19. </build>
  • jetty配置

启动命令:jetty:run

  1. <build>
  2. <finalName>demo</finalName>
  3. <plugins>
  4. <plugin>
  5. <groupId>org.mortbay.jetty</groupId>
  6. <artifactId>jetty-maven-plugin</artifactId>
  7. <version>7.4.4.v20110707</version>
  8. <configuration>
  9. <scanIntervalSeconds>5</scanIntervalSeconds>
  10. <webAppConfig>
  11. <contextPath>/demo</contextPath>
  12. </webAppConfig>
  13. <connectors>
  14. <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
  15. <port>80</port>
  16. </connector>
  17. </connectors>
  18. </configuration>
  19. </plugin>
  20. </plugins>
  21. </build>

0
0
0

添加评论

正在回复:
取消
0
0
0
0