Eclipse maven run configuration using 'run' goal from tomcat7 maven plugin doesn't respect default context path

白昼怎懂夜的黑 提交于 2020-01-04 04:03:55

问题


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.


回答1:


When experiencing problems with maven they mostly get solved by using the clean plugin (mvn clean) which cleans out your project's working directory.

http://maven.apache.org/plugins/maven-clean-plugin/



来源:https://stackoverflow.com/questions/19187468/eclipse-maven-run-configuration-using-run-goal-from-tomcat7-maven-plugin-doesn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!