In this example, we'll see how to configure Maven to run a project on tomcat withing eclipse. It is sometimes too hard to manage the Maven project with the commands. Each time we code the project in IDE like eclipse and go to the terminal/cmd to clean, build or install with the appropriate mvn commands.
I am writing this blog to simplify this process. You just need to follow the steps below and I am sure it would make you feel too comfort to run your Maven project within the IDE.
Setup your Maven project and an instance of tomcat7 in eclipse before following steps.
So here are the steps -
1. Add the following plugin to your POM's plugins tag -
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<port>8088</port>
<path>/</path>
</configuration>
</plugin>
2. Configure your Maven Run Configuration -
a) Right button click on project -> Run As -> Run Configurations.
b) Select Maven Build in left panel, click Right button click and select New.
c) Give the name to the Run Configuration.
d) Provide the goals separated with a space. Please notice, tomcat7:run is the ultimate goal to start the tomcat7. (For example - clean install tomcat7:run)
e) Provide the Profile if any.
f) Apply and Run.
That's it.
Thanks and Happy coding.
0 Comment(s)