Spring 3.1 - Servlet 3 code-based configuration using the Jetty Maven Plugin

眉间皱痕 提交于 2019-12-06 11:15:51

问题


I try to integrate the new features of spring 3.1 using annotations to specify the configuration information for the web application.

I set up the maven-jetty-plugin version 8.0.4.v20111024 to run my app. While starting jetty using the mvn jetty:run command, everything seems to be ok and set up correctly. But when accessing the app through the browser, there is just the output of the default servlet.

It seems to be a simular issue, that tomcat had in previous versions (<=7.0.14) https://issues.apache.org/bugzilla/show_bug.cgi?id=51278

Currently, I can not use jetty and I had to switch to the tomcat-plugin to deploy my application to tomcat.

Has anyone any suggestions, how to overwrite the jetty default servlet, when no web.xml is available?


回答1:


You do it by overriding the default jetty config, put this in your plugin:

<configuration>
  <scanIntervalSeconds>0</scanIntervalSeconds>
  <webAppConfig>
    <defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor>
  </webAppConfig>
</configuration>

Copy the webdefault file from Jetty, and comment out this part:

<!--   <servlet-mapping> -->
<!--     <servlet-name>default</servlet-name> -->
<!--     <url-pattern>/</url-pattern> -->
<!--   </servlet-mapping> -->


来源:https://stackoverflow.com/questions/8066943/spring-3-1-servlet-3-code-based-configuration-using-the-jetty-maven-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!