Using multiple repositories in Maven

后端 未结 4 1074
逝去的感伤
逝去的感伤 2021-01-12 06:57

I have a project that uses an internal repository and the central repository. Is there a way I can configure the settings.xml such that I can use both instead of just one? W

4条回答
  •  离开以前
    2021-01-12 07:32

    I use three repos (using Nexus), the first one is a Proxy repository to which I add all external repositories. The other two are my internal repositories for deployment of releases and snapshots. Here is my .m2/settings.xml:

    
        
    
        true
        false
    
        
        
            nexus
            external:*
            http://localhost:3129/nexus/content/groups/public
        
        
    
        
        
            nexus
            
                
                    central
                    http://central
                    
                        true
                    
                    
                        true
                    
                
    
                
                    internal.releases
                    http://localhost:3129/nexus/content/repositories/releases
                    
                        true
                    
                    
                        false
                    
                        
    
                
                    internal.snapshots
                    http://localhost:3129/nexus/content/repositories/snapshots
                    
                        false
                    
                    
                        true
                    
                        
            
    
            
                
                    central
                    http://central
                    
                        true
                    
                    
                        true
                    
                
            
            
                true
                true           
            
        
        
    
        
        nexus
          
    
        
        
            internal.releases
            admin
            XXX
        
        
            internal.snapshots
            admin
            XXX
        
        
    
    
    

    Maven uses them all, so you might want to use the Routing feature of Nexus to block "^/my/private/packages/.*" so it does not try to fetch internal packages from external repositories. I haven't added the internal repos to the proxy repo.

    You don't need to adjust your pom.xml files for that to work. Just enter "mvn deploy".

提交回复
热议问题