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

后端 未结 8 2085
伪装坚强ぢ
伪装坚强ぢ 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:25

    In a Maven module structure like this:

    - parent
      - child1
      - child2
    

    You will have in the parent pom this:

    
      child1
      child2
    
    

    If you now depend on child1 in child2 by putting the following in your in child2:

    
      example
      child1
    
    

    You will receive an error that the JAR for child1 cannot be found. This can be solved by declaring a block including child1 in the pom for parent:

    
      
        
          example
          child1
          ${project.version}
        
      
    
    

    child1 will now be build when you run a compile or package etc. goal on parent, and child2 will find child1's compiled files.

提交回复
热议问题