1. Download the unzipped version of Tomcat and configure the environment variables to enable Tomcat to start successfully.
Using the unzipped version of Tomcat makes it easy to see the error messages of Tomcat's background output for easy debugging.
2. Configure the user name password for tomcat.
Modify the/config/tomcat-user.xml in the Tomcat installation directory to read as follows:
<?xml version= ' 1.0 ' encoding= ' cp936 '? <tomcat-users ; <role rolename =< Span class= "Hljs-value" > "Manager-gui" /> < Role rolename = "Manager-script" /> <user username = "username" password = "password" roles = "Manager-gui,manager-script" /> </tomcat-users ;
The purpose of the above configuration file is to add a user named "username" to tomcat with a password of "password" and a permission of "Manager-gui".
3. Add the following code to the MAVEN project's pom.xml.
<plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <artifactid>Maven-compiler-plugin</artifactid> <version>2.3.2</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/text</URL> <username>Username</username> <password>Password</password> <path>/${project.artifactid}</path> </configuration> </plugin> </plugins>
4. Deploy the App
If you use Eclipse, right-click Project->run as->maven build...-> enter tomcat7:deploy in goals;
If you are using MAVEN directly, execute the command:
mvntomcat7:deploy
Maven deploys web apps directly to Tomcat