利用Maven将项目打包上传到nexus私服共享
1、pom.xml文件添加distributionManagement节点
<!-- 使用分发管理将本项目打成jar包,直接上传到指定服务器(私服) --> <distributionManagement> <!--正式版本--> <repository> <!-- setting.xml中配置私服用户名和密码 --> <id>releases</id> <name>Release Repository</name> <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url> </repository> <!--快照版本--> <snapshotRepository> <!-- setting.xml中配置私服用户名和密码 --> <id>snapshots</id> <name>Snapshots Repository</name> <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
2、setting.xml文件节点配置
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>D:\repo</localRepository> <servers> <server> <!-- 需要与pom.xml中的distributionManagement>repository>id一致 --> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <!-- 需要与pom.xml中的distributionManagement>repository>id一致 --> <id>snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers> <mirrors> <!-- 私库配置 --> <mirror> <id>public</id> <mirrorOf>*</mirrorOf> <name>私库 公共仓库</name> <url>http://127.0.0.1:8081/nexus/content/groups/public</url> </mirror> <!-- https://developer.aliyun.com/mvn/guide --> <mirror> <id>aliyunmaven</id> <mirrorOf>*</mirrorOf> <name>阿里云 公共仓库</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> </mirrors> <profiles> <profile> <id>dev</id> <repositories> <repository> <id>public</id> <name>私库 代理仓</name> <url>http://127.0.0.1:8081/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring</id> <name>spring 代理仓</name> <url>https://maven.aliyun.com/repository/spring</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-plugin</id> <name>spring-plugin 代理仓</name> <url>https://maven.aliyun.com/repository/spring-plugin</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>public</id> <name>私库 代理仓</name> <url>http://127.0.0.1:8081/nexus/content/groups/public/</url> </pluginRepository> <pluginRepository> <id>spring</id> <name>spring 代理仓</name> <url>https://maven.aliyun.com/repository/spring</url> </pluginRepository> <pluginRepository> <id>spring-plugin</id> <name>spring-plugin 代理仓</name> <url>https://maven.aliyun.com/repository/spring-plugin</url> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles> </settings>
3、执行deploy上传至远程仓库
4、查看远程仓库是否存在
千万不要试图去研究 研究了很久都整不明白的东西,或许是层次不到,境界未到,也或许是从未在实际的应用场景接触过,这种情况下去研究,只会事倍功半,徒劳一番罢了。能做的就是不断的沉淀知识,保持一颗积极向上的学习心态,相信终有一天所有的困难都会迎刃而解。