我目前正在尝试设置一个与我的 maven 项目的 artifactId 不同的路径。不幸的是,我的尝试没有奏效。
我试过设置它
<build>
<plugins>
[...]
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/AWV</path>
</configuration>
</plugin>
</plugins>
<finalName>AWV</finalName>
</build>
但是当调用 mvn tomcat7:run-war
时,它们都不起作用(但 war 被正确地命名为 AWV.war)。
我能找到的所有文档(http://mojo.codehaus.org/tomcat-maven-plugin/configuration.html、http://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/run-war-mojo.html)都说我可以通过这种方式设置路径来做到这一点。
或者,我尝试使用 mvn tomcat7:run-war -Dmaven.tomcat.path=/AWV
运行 tomcat,但这也不起作用。其他提示,例如在 ( Eclipse maven run configuration using 'run' goal from tomcat7 maven plugin doesn't respect default context path ) 之前执行 clean
也不起作用。
有人知道如何解决这个问题吗?
编辑:使用 tomcat-maven-plugin 的 2.3-SNAPSHOT 时也会发生这种情况。
最佳答案
找了一段时间,发现错误:在src/main/webapps/META-INF/context.xml
中有这样的文字:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/awv-seite"/>
我不知道这个文件是如何到达那里的,可能是 eclipse 或 NetBeans 创建的。这阻止了我所有其他尝试的成功,在那里设置路径后,一切正常。
关于java - Maven tomcat 插件不接受路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24996702/