With
maven tomcat7 plugin you won't have download,install and configure
Tomcat server seperately.
Maven can do it for you.Just run:
mvn tomcat7:run
with a tomcat7 maven plugin enabled project and browse to
localhost:port/path
In your
pom.xml simply put this plugin:
- <plugin>
- <groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <server>tomcat-development-server</server>
- <port>9966</port> <!--make sure port doesnt conflict with others -->
- <path>/SpringMVC</path><!--http:
- </configuration>
- </plugin>
Example spring maven hello world web 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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.mohi</groupId>
- <artifactId>SpringMVC</artifactId>
- <packaging>war</packaging>
- <version>1.0-SNAPSHOT</version>
- <name>SpringMVC Maven Webapp</name>
- <url>http:
- <dependencies>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>4.0.3.RELEASE</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <server>tomcat-development-server</server>
- <port>9966</port>
- <path>/SpringMVC</path>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </project>
Sample code:
Download ,unzip and run:
mvn clean install tomcat7:run
Browse to localhost:9966/SpringMVC/welcome