创建maven项目——为啥创建一个maven项目之后,项目上面有一个小红叉,但又没有说哪里错

创建项目

1、

2、

3、

4、发现报错

5、报错信息

Description Resource Path Location Type Dynamic Web Module 3.0 requires Java 1.6 or newer.

Description Resource Path Location Type
One or more constraints have not been satisfied. programing line 1 Maven Java EE Configuration Problem

 

6、原因

用maven创建java工程时,默认的编译版本是jdk1.5。你的 Maven 编译级别是 jdk1.5 或以下,而你导入了 jdk1.6 以上的依赖包

 

7、解决办法(我使用的是第二种方法)

第一种:可以在setting.xml中改变默认的编辑版本,在Setting.xml文件中的激活profile中添加以下属性:

  <properties>  

          <maven.compiler.source>1.6</maven.compiler.source>  

          <maven.compiler.target>1.6</maven.compiler.target>  

          <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>  

      </properties>  

 

第二种:在项目的pom文件中,加入以下配置:

<build>
        <plugins>
            <!-- define the project compile level -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

之后需要更新项目

 

 

就可以了

 

这样创建的项目src/main/webapp里面没有WEB-INF、web.xml那些文件及文件夹

你可以右键点击项目并选择属性properties,

这样就可以了。

 

posted @ 2021-04-16 20:53  kongbursi  阅读(168)  评论(0编辑  收藏  举报