Maven doesn't recognize sibling modules when running mvn dependency:tree

后端 未结 8 2041
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 04:31

I\'m trying to set up a multi-module Maven project, and the inter-module dependencies are apparently not being set up correctly.

I have:



        
相关标签:
8条回答
  • 2020-12-02 05:05

    The only thing that workd for me : switching to gradle :(

    I have

    Parent
      +---dep1
      +---war1 (using dep1)
    

    and I can just cd in war1 and use mvn tomcat7:run-war. I always have to install the whole project before, despite war1 references his parent and the parent references war1 and dep1 (as modules) so all dependencies should be known.

    I don't understand what the problem is.

    0 讨论(0)
  • 2020-12-02 05:11

    I think the problem is that when you specify a dependency Maven expects to have it as jar (or whatever) packaged and available from at least a local repo. I'm sure that if you run mvn install on your commons project first everything will work.

    0 讨论(0)
  • 2020-12-02 05:12

    Bonusing off the answer from Don Willis:

    If your build creates test-jars to share test code among your reactor submodules you should use:

    mvn test-compile dependency:tree
    

    which will allow dependency:tree to run to completion in this case.

    0 讨论(0)
  • 2020-12-02 05:20

    Make sure the module which is failing gets resolved in the pom, is pointing to the right parent by including the configurations in the pom file of the module.

    0 讨论(0)
  • 2020-12-02 05:21

    As discussed in this maven mailing list thread, the dependency:tree goal by itself will look things up in the repository rather than the reactor. You can work around this by mvn installing, as previously suggested, or doing something less onerous that invokes the reactor, such as

    mvn compile dependency:tree
    

    Works for me.

    0 讨论(0)
  • 2020-12-02 05:22

    for me, what led me to this thread was a similar problem and the solution was to ensure all module dependency pom's had

     <packaging>pom</packaging>
    

    the parent had

    pom

    my model dep had pom - so there was no jar to be found.

    0 讨论(0)
提交回复
热议问题