【问题标题】:Cannot change version of project facet Dynamic Web Module to 3.1无法将项目方面动态 Web 模块的版本更改为 3.1
【发布时间】:2018-10-26 15:01:36
【问题描述】:

为什么 maven 坚持在我的 eclipse 项目中将我的 Dynamic Web Module 更改为 3.1?我希望它保持 4.0。有没有办法告诉 maven 我想要 Servlet spec 4.0?到目前为止,Maven 文档还没有为我提供答案。

这是我的 pom 的一部分:

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <inherited>true</inherited>
            <configuration>
                <source>10</source>
                <target>10</target>
            </configuration>
      </plugin>
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.2.1</version>
          <configuration>
              <failOnMissingWebXml>false</failOnMissingWebXml>
          </configuration>
      </plugin>

Servlet 罐子:

<dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>4.0.1</version>
          <scope>provided</scope>             
</dependency>

Eclipse 项目设置:

m2e 错误:

我在 Java 10 和 tomcat 9 中使用 Eclipse 氧气。我尝试关闭并重新打开我的项目,进行一些小的更改,然后 Maven 更新我的项目,删除 maven 配置错误以查看它们是否在更新后返回(它们回来)和其他类似的试错类型的东西。到目前为止,没有任何效果。

【问题讨论】:

    标签: java eclipse maven m2eclipse servlet-4


    【解决方案1】:

    相关错误:https://bugs.eclipse.org/bugs/show_bug.cgi?id=530958

    请尝试使用 m2e-wtp 1.4.0。目前,最新的里程碑版本可从http://download.eclipse.org/m2e-wtp/milestones/photon/1.4/ 获得。

    【讨论】:

    • 伙计,太好了。非常感谢! +1。
    【解决方案2】:

    只需使用:

    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
        id="WebApp_ID" version="4.0">
    

    代替:

    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
        id="WebApp_ID" version="3.1">
    

    在您的 web.xml 标头中。

    【讨论】:

      猜你喜欢
      • 2013-08-09
      • 2016-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-29
      • 2016-07-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多