maven深入学习笔记_007配置从私服拉取jar以及上传jar到私服
2020-07-19 04:49
351 查看
一、配置从私服拉取jar
打开maven的setting文件,配置如下
<!-- 强制让jar包下载走私服 --> <mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/repository/maven-public/</url> </mirror> </mirrors> <profiles> <profile> <!-- 对应activeProfiles-activeProfile的内容 --> <id>nexus</id> <!-- 仓库地址 --> <repositories> <repository> <!-- 私服id,覆盖maven-model模块下的父id,让maven不走中央仓库下载,走私服下载 --> <id>central</id> <!-- 名字 --> <name>Nexus</name> <!-- 私服地址,写central后,会去mirror里面找 --> <url>http://central</url> <!-- 支持releases版本 --> <releases> <enabled>true</enabled> </releases> <!-- 支持snapshots版本 --> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <!-- 插件地址 --> <pluginRepositories> <pluginRepository> <id>central</id> <name>Nexus Plugin Repository</name> <url>http://central</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <!-- 选择使用的profile --> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles>
二、配置项目上传到私服
在pom.xml里新增如下配置。
<distributionManagement> <!-- releases仓库 --> <repository> <!-- id,对应maven的setting.xml里面server配置的id --> <id>nexus-releases</id> <!-- 自定义的名字 --> <name>Nexus Release Repository</name> <!-- releases仓库url --> <url>http://localhost:8081/repository/maven-releases/</url> </repository> <!-- snapshots仓库 --> <snapshotRepository> <!-- id,对应maven的setting.xml里面server配置的id --> <id>nexus-snapshots</id> <!-- 自定义的名字 --> <name>Nexus Snapshot Repository</name> <!-- snapshots仓库url --> <url>http://localhost:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> <!-- 编译打包插件 --> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>${java.version}</source> <target>${java.version}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> </plugins> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> </resources> </build>
打开maven的setting文件,配置如下
<!-- 登录远程仓库的用户名和命令 --> <servers> <server> <!-- id,对应项目里面pom.xml里面distributionManagement配置的id --> <id>nexus-releases</id> <!-- 登录nexus的用户名 --> <username>xxx</username> <!-- 登录nexus的密码 --> <password>xxx</password> </server> <server> <!-- id,对应项目里面pom.xml里面distributionManagement配置的id --> <id>nexus-snapshots</id> <!-- 登录nexus的用户名 --> <username>xxx</username> <!-- 登录nexus的密码 --> <password>xxx</password> </server> </servers>
执行
mvn clean deploy就可以把项目打包上传到私服。
三、第三方jar上传到私服
执行命令:
mvn deploy:deploy-file -DgroupId=com.xxx.xxx.xxx -DartifactId=xxx-xxx -Dversion=1.0 -Dpackaging=jar -Dfile=D:\xxx-1.0.jar -Durl=http://localhost:8081/repository/maven-Third-party/ -DrepositoryId=maven-Third-party
- deploy:deploy-file:上传jar命令
- -DgroupId:groupId
- -DartifactId:artifactId
- -Dversion:版本
- -Dpackaging:项目类型
- -Dfile:jar包路径
- -Durl:仓库地址
- -DrepositoryId:仓库id
相关文章推荐
- Maven学习笔记(四)—— 将本地项目打包发布到私服(nexus)上以及在私服上添加第三方Jar包(ojdbc)
- Java 在Linux下使用nexus3搭建Maven私服并且使用Gradle进行jar包上传以及依赖下载
- CentOS安装Nexus(Maven私有库)详细配置及上传本地jar到私服
- Maven基础配置—上传jar包到私服
- Maven基础配置—上传jar包到私服
- Maven基础配置—上传jar包到私服
- maven 私服配置上传私有jar
- maven 上传jar到私服 pom 以及命令的方式
- 私服库,maven本地库,maven库,jar库,架包库,本地架包库,本地jar库,jar包库 关于maven私服架包上传配置
- Maven基础配置—上传jar包到私服
- maven私服配置上传jar到nexus
- CentOS安装Nexus(Maven私有库)详细配置及上传本地jar到私服
- Maven基础配置—上传jar包到私服
- MyEclipse 配置maven项目pom.xml设置 上传项目到nexus私服,通过中转仓库下载插件,以及nexus的配置
- Maven基础配置,上传jar包到私服
- Maven学习二:Maven配置本地仓储与远程仓储完整步骤以及修改settings.xml完成后完整内容(非私服,远程仓储镜像强力推荐阿里云)
- Maven学习笔记二:Nexus私服搭建
- Maven学习笔记十:Maven坐标和依赖(依赖的配置)
- Maven:将Jar安装到本地仓库和Jar上传到私服
- 版本控制器git 学习笔记(Git安装以及配置)