I'm working on a web service locally, built using maven and deploying to tomcat. I'm using the maven plugin to run locally, using mvn tomcat:run
as my run configuration.
Right now, my service is being deployed using the default project name as a context path:
http://localhost:8080/myArtifactId/servletPath
I would instead like to deploy to remove the context path, and deploy to this url through configuring the tomcat maven plugin:
http://localhost:8080/servletPath
Per this documentation: http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/usage.html
I am trying this:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- Why isn't this working??? -->
<path>/</path>
</configuration>
</plugin>
Any ideas on why what I'm trying isn't working, or a different way I can go about this? As I've stated, I'm trying to do this through the maven plugin.
Alternatively, does anyone know how to pass this in as an argument to the run configuration? Maybe passing it in explicitly at the command line will override the default.
UPDATE: Running mvn tomcat7:run
or mvn clean tomcat7:run
from the command line appears to make this work as intended. But when I run using a Maven Build
run configuration in Eclipse, the service is started using the default artifact ID, regardless of what I put in the path variable in my pom.xml
.
UPDATE: This appears to be a problem with the Eclipse Maven plugin. When I run the command from the command line, everything works as expected but when trying to add an Eclipse/Maven run configuration with a Tomcat7:run goal, the project keeps running using the default artifact id context path.
When experiencing problems with maven they mostly get solved by using the clean plugin (mvn clean
) which cleans out your project's working directory.