简体   繁体   English

Spring 3.1-使用Jetty Maven插件的基于Servlet 3代码的配置

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

I try to integrate the new features of spring 3.1 using annotations to specify the configuration information for the web application. 我尝试使用注释集成spring 3.1的新功能,以指定Web应用程序的配置信息。

I set up the maven-jetty-plugin version 8.0.4.v20111024 to run my app. 我设置了maven-jetty-plugin版本8.0.4.v20111024来运行我的应用程序。 While starting jetty using the mvn jetty:run command, everything seems to be ok and set up correctly. 使用mvn jetty:run命令启动码头时,一切似乎正常,并正确设置。 But when accessing the app through the browser, there is just the output of the default servlet. 但是,当通过浏览器访问应用程序时,只有默认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 Tomcat以前的版本(<= 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. 当前,我不能使用码头,我不得不切换到tomcat插件来将我的应用程序部署到tomcat。

Has anyone any suggestions, how to overwrite the jetty default servlet, when no web.xml is available? 有没有任何建议,在没有web.xml时如何覆盖码头默认servlet?

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: 从Jetty复制webdefault文件,并注释掉这部分:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM