Is there a way to exclude a Maven dependency globally?

后端 未结 4 479
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 20:53

I’m trying to find a “generic” way of excluding a transitive dependency from being included without having to exclude it from all the dependencies that depend on it. For ex

4条回答
  •  旧巷少年郎
    2020-11-30 21:03

    To expand on dnault's comment:

    One can use the Maven Enforcer plugin's Banned Dependencies rule to ensure dependencies are excluded. One still has to exclude them manually, but the build will fail if anyone adds the dependency elsewhere by mistake.

    
      
        org.hibernate
        hibernate-jmx
        3.3.2.GA
        
          
            org.slf4j
            slf4j-api
          
        
      
    
    
    
      
        org.apache.maven.plugins
        maven-enforcer-plugin
        1.4.1
        
          
            
              enforce
            
            
              
                
                  
                    org.slf4j:slf4j-api
                  
                
              
            
          
        
      
    
    

    Also there is an open feature request: MNG-1977 Global dependency exclusions

提交回复
热议问题