多模块Maven项目和码头:运行 [英] Multi-module Maven project and jetty:run
问题描述
我试图将Maven WAR项目分成两个模块,以便可以使用命令行工具构建单独的JAR文件.结果具有以下结构:
I'm trying to split a Maven WAR project into two modules, so that I can build a separate JAR file with command line tools. The result has the following structure:
-
pom.xml
(包装pom
,有两个模块) -
project-jar/
-
pom.xml
(包装jar
)
pom.xml
(packagingpom
, has two modules)project-jar/
pom.xml
(packagingjar
)
-
pom.xml
(包装war
,取决于project-jar
)
pom.xml
(packagingwar
, depends onproject-jar
)
如果我从根目录运行
mvn
命令,则一切正常.我想继续使用mvn jetty:run
,但是为此,我需要在WAR子项目中执行命令.如果这样做,将无法找到project-jar
子项目,因此它将无法运行.即使mvn jetty:run-war
在target
目录中具有完全组装的WAR文件,也会失败,因为它首先尝试构建"项目.我只能通过将project-jar
安装到本地Maven存储库中来使其工作,这不是很好.If I run
mvn
commands from the root, everything works fine. I'd like to keep usingmvn jetty:run
, but for that I need to execute the command in the WAR subproject. If I do that, fails to find theproject-jar
subproject, so it won't run. Evenmvn jetty:run-war
with a completely assembled WAR file in thetarget
directory fails, because it first tries to "build" the project. I've only managed to make it work by installingproject-jar
into the local Maven repository, which isn't very nice.是否可以在多模块Maven配置中使用Jetty插件?
Is there a way to use the Jetty plugin in a multi-module Maven configuration?
推荐答案
没有神奇的解决方案,我知道的唯一解决方案是有点骇人听闻,它依赖于您可以用来声明额外的类目录的
extraClasspath
元素,相对地.像这样(来自 JETTY-662 ):There is no magical solution and the only one I know is a bit hacky and rely on the
extraClasspath
element that you can use to declare extra class directories, relatively. Like this (from JETTY-662):<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>7.0.1.v20091125</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> <webAppConfig> <contextPath>/my-context</contextPath> <extraClasspath>target/classes;../my-jar-dependency/target/classes</extraClasspath> </webAppConfig> <scanTargets> <scanTarget>../my-jar-dependency/target/classes</scanTarget> </scanTargets> </configuration> </plugin>
这篇关于多模块Maven项目和码头:运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-