windows搭建maven私服

    技术2022-07-16  82

    下载

    http://www.sonatype.org/nexus/downloads/

    https://www.sonatype.com/download-nexus-repo-oss?submissionGuid=025d9031-db27-4fcd-9f93-5d71ce2072e2

    启动

    nexus.exe /run

    访问http://localhost:8081/

    登录

    项目发布到私服

     

    配置

    修改maven安装目录下的/conf/settings.xml文件

    <server> <id>maven-releases</id> <username>admin</username> <password>admin</password> </server>

    配置项目pom.xml

    <!-- 打包发布 --> <distributionManagement> <repository> <id>maven-releases</id> <url>http://localhost:8081/repository/maven-releases/</url> </repository> </distributionManagement>

    打包发布

    http://localhost:8081/#browse/browse

    创建资源

    可以修改是否允许更新部署

    手动上传jar

    http://localhost:8081/#browse/upload

    打勾Generate a POM file with these coordinates,否则下载jar包报错Could not find artifact

    从私服下载jar包

    在setting.xml中配置仓库

    <profile> <!--profile的id--> <id>dev</id> <repositories> <repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复--> <id>nexus</id> <!--仓库地址,即nexus仓库组的地址--> <url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases构件--> <releases> <enabled>true</enabled> </releases> <!--是否下载snapshots构件--> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 --> <pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 --> <id>public</id> <name>Public Repositories</name> <url>http://localhost:8081/nexus/content/groups/public/</url> </pluginRepository> </pluginRepositories> </profile> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>

    项目pom.xml

    <repositories> <repository> <id>3rd_party</id> <url>http://localhost:8081/repository/3rd_party/</url> </repository> </repositories>

    Processed: 0.009, SQL: 9