Changing Dynamic Web Module version in Eclipse Maven Project

后端 未结 3 1689
轮回少年
轮回少年 2020-12-29 06:58

I\'m trying to set up Dynamic Web Module 3.0 in order to support Java 6 development. I\'m getting this error in my Problems tab of eclipse whenever I do Maven > Update

相关标签:
3条回答
  • 2020-12-29 07:23

    you can add this to the pom.xml:

    <build>
        <plugins>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        </plugins>
    </build>
    

    Works in Spring STS 3.6.3 :)

    edit:

    source: http://crunchify.com/how-to-solve-dynamic-web-module-3-1-requires-java-1-7-or-newer-in-eclipse/

    0 讨论(0)
  • 2020-12-29 07:23

    Try changing your JRE/JDK version to 1.7. The web project module doesn't support 1.6.

    0 讨论(0)
  • 2020-12-29 07:29

    In an our project, we add to change the web.xml root element's declaration, changing from:

    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    

    to:

    <web-app xmlns="http://java.sun.com/xml/ns/javaee" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
             version="2.5" >
    

    Probably Eclipse were expecting it as satisfying a different Servlet version spec. In our case too, we had neither compile nor runtime problems.

    EDIT: In your case, where you were not using a web.xml file, there was the following pom's dependency which probably was confusing Eclipse's maven plugin:

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

    Change it to "3.0.1". (It turns out that WebApplicationInitializer requires "Servlet 3.0+ environments" and not 3.1+)

    0 讨论(0)
提交回复
热议问题