How to inherit dependency from a parent pom to a child pom

后端 未结 4 542
借酒劲吻你
借酒劲吻你 2020-12-23 17:10

I am new in using maven and jenkins. I am trying to inherit the dependencies from parent pom to child pom it shows the following errors:

[ERROR] COMPILATION          


        
4条回答
  •  天涯浪人
    2020-12-23 17:54

    In fact, you've got 2 ways to deal with the problem.

    1. Either you factor the dependencies in the parent pom under the node and in each child that requires it, add the dependency in the node. You can choose not to set the version of the dependency.
    2. Or you declare the dependencies in the parent pom in the node, and each child will benefit from the dependency.

    So for example, if you declare this in the parent pom:

    
        
            org.slf4j
            slf4j-api
            1.7.21
        
    
    
        
            
                org.slf4j
                slf4j-simple
                1.7.21
                runtime
            
        
    
    

    Then slf4j-api will be a dependency for all children. However, you will have to add a dependency on slf4j-simple in the child's pom, should it require it:

    
        
            org.slf4j
            slf4j-simple
        
    
    

    For the plugins, it works the same, but with the and nodes. All configuration can go in the parent pom's definition of the plugin, and you simply declare the plugin in the section of your child pom.

提交回复
热议问题