2014-05-21 21 views
9

Sto cercando di aggiungere una dipendenza da tomcat7-maven-plug al file pom.xml e ottenere un errore. Sto seguendo le istruzioni su tomcat.apache.org.Come configurare "tomcat7-maven-plugin" in pom.xml?

enter image description here

cvc-complex-type.2.4.a: Invalid content was found starting with element 'configuration'. One of '{"http://maven.apache.org/POM/4.0.0":type, "http:// 
maven.apache.org/POM/4.0.0":classifier, "http://maven.apache.org/POM/4.0.0":scope, "http://maven.apache.org/POM/4.0.0":systemPath, "http:// 
maven.apache.org/POM/4.0.0":exclusions, "http://maven.apache.org/POM/4.0.0":optional}' is expected. 

mio pieno pom.xml config

<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.tastyminerals.poems</groupId> 
    <artifactId>poemcollection</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.3</version> 
      </plugin> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <properties> 
     <hibernate.version>4.3.5.Final</hibernate.version> 
     <mysql.connector.version>5.1.30</mysql.connector.version> 
     <spring.version>4.0.3.RELEASE</spring.version> 
    </properties> 
    <dependencies> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>${hibernate.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>${hibernate.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>${mysql.connector.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-dbcp</groupId> 
      <artifactId>commons-dbcp</artifactId> 
      <version>1.4</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-tx</artifactId> 
      <version>4.0.3.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>javassist</groupId> 
      <artifactId>javassist</artifactId> 
      <version>3.12.1.GA</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib</artifactId> 
      <version>3.1</version> 
     </dependency> 
     <dependency> 
      <groupId>jstl</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-jndi</artifactId> 
      <version>8.1.14.v20131031</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.tomcat.maven</groupId> 
      <artifactId>tomcat7-maven-plugin</artifactId> 
      <version>2.2</version> 
      <configuration> 
       <url>http://localhost:8080/manager</url> 
       <server>localhost</server> 
       <path>/${project.build.finalName}</path> 
      </configuration> 
     </dependency> 
    </dependencies> 
</project> 

risposta

19

Il Tomcat7-maven-plugin dovrebbe essere dichiarato come un plugin, non è una dipendenza. Non è possibile aggiungere un tag di configurazione a una dipendenza come indicato dall'errore.

Così qualcosa come il seguente dovrebbe funzionare:

<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.tastyminerals.poems</groupId> 
<artifactId>poemcollection</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>war</packaging> 
<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 
     <plugin> 
     <groupId>org.apache.tomcat.maven</groupId> 
     <artifactId>tomcat7-maven-plugin</artifactId> 
     <version>2.2</version> 
     <configuration> 
      <url>http://localhost:8080/manager</url> 
      <server>localhost</server> 
      <path>/${project.build.finalName}</path> 
     </configuration> 
     </plugin> 
    </plugins> 
</build> 
<...> 
    </project> 
0

affronto anche la questione, quando schiero la molla web MVC run applicazione come server di

<!-- https://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat8-maven-plugin --> 

<dependency> 
    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat8-maven-plugin</artifactId> 
    <version>3.0-r1756463</version> 
</dependency> 

questo funziona per me

Problemi correlati