Maven配置远程仓库

当构建一个Maven项目时,首先检查pom.xml文件以确定依赖包的下载位置,执行顺序如下:

1、从本地资源库中查找并获得依赖包,如果没有,执行第2步。

2、从Maven默认中央仓库中查找并获得依赖包(http://repo1.maven.org/maven2/),如果没有,执行第3步。

3、如果在pom.xml中定义了自定义的远程仓库,那么也会在这里的仓库中进行查找并获得依赖包,如果都没有找到,那么Maven就会抛出异常。

配置远程仓库:

远程仓库一般是国内镜像以及用nexus私有仓库居多。在pom.xml配置远程仓库时,顺序也是关键点,是从上往下开始查找的。

在pom.xml的repositories节点上添加远程仓库地址,下面整理了一份比较常用的国内远程仓库地址。

  
    
    
        
        
        
            oschina-repos
            Oschina Releases
            http://maven.oschina.net/content/groups/public
        
        
        
            aliyun-repos
            aliyun Releases
            http://maven.aliyun.com/nexus/content/groups/public/
        

        
            java-repos
            Java Repository
            https://maven.java.net/content/repositories/public/
        
        
        
            JBoss-repos
            JBoss Repository
            http://repository.jboss.org/nexus/content/groups/public/
        

        
            springsource-repos
            SpringSource Repository
            http://repo.spring.io/release/
        
        
        
            central-repos
            Central Repository
            http://repo.maven.apache.org/maven2
        
        
        
            central-repos2
            Central Repository 2
            http://repo1.maven.org/maven2/
        
        
        
            activiti-repos
            Activiti Repository
            https://maven.alfresco.com/nexus/content/groups/public
        
        
        
            activiti-repos2
            Activiti Repository 2
            https://app.camunda.com/nexus/content/groups/public
        
        
         
            easonjim-repos 
            EasonJim Repository
            https://raw.github.com/easonjim/repository/master
        
        
    

其中,比较值得推荐的就是github的raw资源也可以作为远程仓库地址,比如我可以上次一些自定义的包,转为自己的raw资源固定一个地址,配置如上https://raw.github.com/easonjim/repository/master的地址之后maven即可查找下载。如果有需要可以自行查找这方面的资料,关键字:github raw

你可能感兴趣的:(maven,java,spring,maven)