新建maven工程时pom.xml报错

Posted 阿泰555

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了新建maven工程时pom.xml报错相关的知识,希望对你有一定的参考价值。

新建maven工程时,pom.xml报错:
第一行报如下错误:
multiple annotations found at this line
后添加org.eclipse.m2e相关的plugin配置后,错误消失,完整pom.xml如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.pig2014</groupId>
    <artifactId>pig2014</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>pig2014 Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-resources-plugin</artifactId>
                                        <versionRange>[2.0,)</versionRange>
                                        <goals>
                                            <goal>resources</goal>
                                            <goal>testResources</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-compiler-plugin</artifactId>
                                        <versionRange>[2.0,)</versionRange>
                                        <goals>
                                            <goal>compile</goal>
                                            <goal>testCompile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

注:以下提供一个可用pom.xml内容:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.pig2014</groupId>
  <artifactId>pig2014</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>pig2014</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jsoup</groupId>
      <artifactId>jsoup</artifactId>
      <version>1.8.1</version>
    </dependency>
  </dependencies>
</project>

 




以上是关于新建maven工程时pom.xml报错的主要内容,如果未能解决你的问题,请参考以下文章

新建maven项目出错 pom.xml报错

新建maven项目pom.xml文件报错

Eclipse创建Maven工程总是出现pom.xml报错怎么办

Eclipse创建Maven工程总是出现pom.xml报错怎么办

1、父工程Project空间新建、父工程pom文件、介绍DependencyManagement和Dependencies

Eclipse创建Maven工程总是出现pom.xml报错怎么办