开发者

Running maven project with eclipse dependencies outside eclipse

开发者 https://www.devze.com 2023-03-30 18:40 出处:网络
I\'m developing a maven project with several modules in eclipse. The parent pom.xml declares all submodules, and every submodule contains a pom.xml with a reference to the parent. Some submodules are

I'm developing a maven project with several modules in eclipse. The parent pom.xml declares all submodules, and every submodule contains a pom.xml with a reference to the parent. Some submodules are dependent on other submodules, so I have added them as a dependency (m2e finds them when searching for dependencies). However, when I try to run a submodule outside eclipse using jetty (mvn -pl submodule jetty:run), I get the error that it is missing the other submodules.

In other words, and more elaborate: there's parent, sub1 and sub2. sub2 depends on sub1. I added

<modules>
  <module>sub1</module>
  &开发者_Python百科lt;module>sub2</module>
</modules>

in the parent and

<parent>
  <groupId>group</groupId>
  <artifactId>parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>

In both sub1 and sub2, and

<dependency> 
  <groupId>group.parent</groupId>
  <artifactId>sub1</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</depdency>

in sub2.

When I run:

mvn -pl sub2 jetty:run

I get:

[INFO] Failed to resolve artifact.

Missing:
----------
1) group.parent:sub1:jar:0.0.1-SNAPSHOT

How can I get maven to find the submodule dependencies?


Have you tried running mvn install in your parent project before running Jetty in the submodule? This will install your jars in your local Maven repository, following which Maven will be able to find them.

(Or I could be grossly misreading the complexity of your question, in which case: please correct me.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号