简体   繁体   English

使用tomcat7 maven插件中的“run”目标的Eclipse maven运行配置不遵循默认上下文路径

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

I'm working on a web service locally, built using maven and deploying to tomcat. 我正在本地使用Web服务,使用maven构建并部署到tomcat。 I'm using the maven plugin to run locally, using mvn tomcat:run as my run configuration. 我正在使用maven插件在本地运行,使用mvn tomcat:run作为我的运行配置。

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 : 我想改为部署以删除上下文路径,并通过配置tomcat maven插件部署到此url:

http://localhost:8080/servletPath

Per this documentation: http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/usage.html 根据此文档: 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. 正如我所说,我试图通过maven插件来做到这一点。

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. 更新:运行mvn tomcat7:runmvn clean tomcat7:run似乎使此工作按预期工作。 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 . 但是当我在Eclipse中使用Maven Build运行配置运行时,无论我在pom.xml中的路径变量中放置什么,都使用默认的工件ID启动服务。

UPDATE: This appears to be a problem with the Eclipse Maven plugin. 更新:这似乎是Eclipse Maven插件的一个问题。 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. 当我从命令行运行命令时,一切都按预期工作,但是当尝试使用Tomcat7:run目标添加Eclipse / Maven运行配置时,项目使用默认的工件ID上下文路径继续运行。

When experiencing problems with maven they mostly get solved by using the clean plugin ( mvn clean ) which cleans out your project's working directory. 当遇到maven问题时,他们大多通过使用清理插件( mvn clean )来解决,它清理了项目的工作目录。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM