使用tomcat7 Maven插件中的“运行"目标的Eclipse Maven运行配置不遵守默认上下文路径 [英] Eclipse maven run configuration using 'run' goal from tomcat7 maven plugin doesn't respect default context path

查看:274
本文介绍了使用tomcat7 Maven插件中的“运行"目标的Eclipse Maven运行配置不遵守默认上下文路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在本地处理Web服务,使用maven构建并部署到tomcat.我正在使用maven插件在本地运行,并使用mvn tomcat:run作为我的运行配置.

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

我想部署以删除上下文路径,并通过配置tomcat maven插件部署到此URL :

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

根据此文档: http://tomcat. apache.org/maven-plugin-2.1/tomcat7-maven-plugin/usage.html

我正在尝试:

        <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>

关于为什么我要尝试的东西不起作用的任何想法,或者我可以采用其他方式解决此问题的任何想法?如前所述,我正在尝试通过Maven插件来做到这一点.

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.

更新:从命令行运行mvn tomcat7:runmvn clean tomcat7:run似乎可以使此工作按预期进行.但是,当我在Eclipse中使用Maven Build运行配置运行时,无论我将pom.xml中的path变量放在什么位置,该服务都是使用默认工件ID启动的.

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.

更新:看来这是Eclipse Maven插件的问题.当我从命令行运行命令时,一切都按预期运行,但是当尝试添加带有Tomcat7:run目标的Eclipse/Maven运行配置时,项目将使用默认的工件ID上下文路径继续运行.

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.

推荐答案

当遇到maven问题时,大多数情况下可以通过使用 clean 插件(mvn clean)来解决,该插件可以清理项目的工作目录.

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 /

这篇关于使用tomcat7 Maven插件中的“运行"目标的Eclipse Maven运行配置不遵守默认上下文路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆