简体   繁体   English

如何为Servlet 3.0配置Spring Boot 1.2.0并让m2e将Eclipse Facet设置为3.0?

[英]How to configure Spring Boot 1.2.0 for Servlet 3.0 and have m2e set Eclipse Facet to 3.0?

With Spring Boot 1.2.0, m2e sets the Eclipse Project Facet "Dynamic Web Project" to 3.1. 使用Spring Boot 1.2.0,m2e将Eclipse Project Facet“动态Web项目”设置为3.1。 This is expected as Spring Boot 1.2.0 newly supports Servlet Spec 3.1. 这是预期的,因为Spring Boot 1.2.0最新支持Servlet Spec 3.1。

However, we need to stay with 3.0 (Tomcat 7), so we set the correct property in our POM per the Boot instructions: 但是,我们需要使用3.0(Tomcat 7),因此我们根据Boot指令在POM中设置正确的属性:

<servlet-api.version>3.0.1</servlet-api.version>

But m2e still sets the Eclipse facet to 3.1, not 3.0. 但m2e仍然将Eclipse方面设置为3.1,而不是3.0。 The problem is Eclipse will not deploy the war to Tomcat 7. 问题是Eclipse不会将战争部署到Tomcat 7。

What else needs setting to make m2e set the facet to 3.0 so we can upgrade to Spring Boot 1.2.0? 还有什么需要设置使m2e将方面设置为3.0,以便我们可以升级到Spring Boot 1.2.0?

This worked for me: 这对我有用:

Add the tomcat version to the pom.xml under < properties> : 将tomcat版本添加到<properties>下的pom.xml中:

<tomcat.version>7.0.59</tomcat.version>

Then go to Properties -> Project Facets, uncheck Dynamic Web Module, then Ok or Apply. 然后转到属性 - >项目构面,取消选中动态Web模块,然后单击确定或应用。 Then do Maven->Update Project... 然后做Maven->更新项目......

The Dynamic Web Module version should have updated to 3.0 动态Web模块版本应已更新至3.0

I found a simple solution: m2e-wtp sets the Eclipse project web facet by looking at web.xml (if it exists) or scanning the classpath for specific servlet api classes (when web.xml not found). 我找到了一个简单的解决方案:m2e-wtp通过查看web.xml(如果存在)或扫描特定servlet api类的类路径(当找不到web.xml时)来设置Eclipse项目web facet。

Therefore, either set the servlet api version in web.xml or set POM property to a non-servlet 3.1 version (eg the Spring Boot 1.1.10's version is 7.0.57). 因此,要么在web.xml中设置servlet api版本,要么将POM属性设置为非servlet 3.1版本(例如,Spring Boot 1.1.10的版本是7.0.57)。 Either approach causes m2e-wtp to set the facet accordingly. 这两种方法都会导致m2e-wtp相应地设置facet。

I am wondering if it is possible to improve m2e-wtp's detection or configuration as currently I don't know how it is possible in this configuration to use Tomcat 8 with servlet 3.0 without a web.xml. 我想知道是否有可能改进m2e-wtp的检测或配置,因为目前我不知道在这种配置中如何使用Tomcat 8和没有web.xml的servlet 3.0。

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

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