Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure "tomcat7-maven-plugin" in pom.xml?

I am trying to add a tomcat7-maven-plugin dependency to pom.xml file and getting an error. I am following the instructions on tomcat.apache.org.

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.

My full 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>
like image 539
minerals Avatar asked May 21 '14 06:05

minerals


People also ask

What is tomcat7 Maven plugin?

The Tomcat7 Maven Plugin provides goals to manipulate WAR projects within the Tomcat servlet container version 7.x.

What is the use of Maven WAR plugin?

The WAR Plugin is responsible for collecting all artifact dependencies, classes and resources of the web application and packaging them into a web application archive.


1 Answers

The Tomcat7-maven-plugin should be declared as a plugin, it is not a dependency. You can't add a configuration tag to a dependency as indicated by the error.

Thus something like the following should work :

<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>
like image 178
Cédric Couralet Avatar answered Nov 03 '22 18:11

Cédric Couralet