Exclude dependency in a profile

后端 未结 6 1981
别那么骄傲
别那么骄傲 2021-02-06 23:49

I have a maven module which has some dependencies. In a certain profile, I want to exclude some of those dependencies (to be exact, all dependencies with a certain group id). Th

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 00:29

    Instead of excluding dependencies in a profile, you can set them as provided in it. This doesn't require any overly complex configuration and will exclude the dependencies you don't want from the final build.

    In the desired profile, add a dependencies section, copy the declaration of the ones you want to exclude and scope them as provided.

    For example, let say you want to exclude slf4j-log4j12:

    
    
        
    
        
            no-slf4j-log4j12
            
                
                    org.slf4j
                    slf4j-log4j12
                    1.7.2
                    provided
                
            
        
    
        
    
    
    

提交回复
热议问题