Getting Started with Maven Tomcat Plug in
to check if tomcat is running:
ps -ef | grep java
getting mysql schema:
mysqldump –no-data -u user -ppassword dbname >schema.sql
Tomcat plugin is good for the deployment of servlet applications into a Tomcat server, it has three major functions:
- Deployment
- Container related goals
- Running an app in an embedded Tomcat Server
This is the functions I used often, I’d consider this as the most important functions of this plug in
Using this group of goals you can query the status of a running Tomcat server.
This is very handy in development, you can run your app even you do not have a tomcat server installed, the embedded server is version 5.5.25 at the time of this writing
To get started you should have a servelet application based on Maven 2 running first, go to the directory of the application where pom.xml is located then try:
maven tomcat:run
pointing your browser at http://localhost:8080/myproject
You should see the program running. that’s the #3 feature listed above.
The easiest way to get started with Plugin is, have a tomcat running at port 8080, add a user ‘admin’ without password to $CATALINA_HOME/conf/tomcat_users.xml:
<user username="admin" password="" roles="standard,manager"/>
try following container related goals:
mvn tomcat:info
mvn tomcat:list
To deploy your app:
mvn tomcat:deploy
mvn tomcat:redeploy
mvn tomcat:undeploy
Now the plug in is running, let’s do something more, I’d prefer to have a installed Tomcat Server running at port 80 and the embedded server at its default port 8080, with that, I can test my app first in the embedded server at port 8080 and deploy it later into the installed Tomcat server and test it in the port 80, of course you can choose whatever port number you like as long as the installed Tomcat server’s port is different from the embedded Tomcat’s port.
- update ./m2/settings.xml
- Add this blog to pom.xml
<servers>
<server>
<id>local_tomcat</id>
<username>admin</username>
<password></password>
</server>
</servers>
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.0-beta-1</version> <configuration> <server>local_tomcat</server> <url>http://localhost:80/manager</url> </configuration> </plugin>
the entry in the settings.xml is actually to specify the user name and password while the port number is specified in the pom.xml’s url part.
leave a comment