问题
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