maven cvc-complex-type.2.4.a: Invalid content was found starting with element 'plugin'.

cvc-complex-type.2.4.a: Invalid content was found starting with element 'plugin'. One of '{"http://maven.apache.org/POM/4.0.0":parent, "http://maven.apache.org/POM/
 4.0.0":description, "http://maven.apache.org/POM/4.0.0":prerequisites, "http://maven.apache.org/POM/4.0.0":issueManagement, "http://maven.apache.org/POM/
 4.0.0":ciManagement, "http://maven.apache.org/POM/4.0.0":inceptionYear, "http://maven.apache.org/POM/4.0.0":mailingLists, "http://maven.apache.org/POM/4.0.0":developers, 
 "http://maven.apache.org/POM/4.0.0":contributors, "http://maven.apache.org/POM/4.0.0":licenses, "http://maven.apache.org/POM/4.0.0":scm, "http://maven.apache.org/POM/
 4.0.0":organization, "http://maven.apache.org/POM/4.0.0":build, "http://maven.apache.org/POM/4.0.0":profiles, "http://maven.apache.org/POM/4.0.0":modules, "http://
 maven.apache.org/POM/4.0.0":repositories, "http://maven.apache.org/POM/4.0.0":pluginRepositories, "http://maven.apache.org/POM/4.0.0":reports, "http://maven.apache.org/
 POM/4.0.0":reporting, "http://maven.apache.org/POM/4.0.0":dependencyManagement, "http://maven.apache.org/POM/4.0.0":distributionManagement}' is expected.


错误的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.zy.demo</groupId>
  <artifactId>demo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  
  <name>demo</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>
  </dependencies>
  <plugin>  
		    <groupId>org.apache.maven.plugins</groupId>  
		    <artifactId>maven-jar-plugin</artifactId>  
		    <version>4.0</version>  
		    <configuration>  
		        <archive>  
		            <manifest>  
		                <addClasspath>true</addClasspath>  
		                <classpathPrefix>lib/</classpathPrefix>  
		                <mainClass>com.zy.demo.demo</mainClass>  
		            </manifest>  
		        </archive>  
		    </configuration>  
		  </plugin>

  
</project>



You have to add the following part in your pom file:

<build>
  <plugins>
   ...<plugin>
      </plugin>
  </plugins>
</build>

正确的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.zy.demo</groupId>
  <artifactId>demo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  
  <name>demo</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>
  </dependencies>
  
  <build>
  	<plugins>
  		<plugin>  
		    <groupId>org.apache.maven.plugins</groupId>  
		    <artifactId>maven-jar-plugin</artifactId>  
		    <version>4.0</version>  
		    <configuration>  
		        <archive>  
		            <manifest>  
		                <addClasspath>true</addClasspath>  
		                <classpathPrefix>lib/</classpathPrefix>  
		                <mainClass>com.zy.demo.demo</mainClass>  
		            </manifest>  
		        </archive>  
		    </configuration>  
		  </plugin>
  	</plugins>
  </build>
  
</project>



你可能感兴趣的:(maven cvc-complex-type.2.4.a: Invalid content was found starting with element 'plugin'.)