Maven deploy配置方法详解

网友投稿 3263 2023-05-13

Maven deploy配置方法详解

Maven deploy配置方法详解

作用

在本地的pom文件配置好之后,执行deploy命令,可以将maven所打的jar包上传到远程的repository,便于其他开发者和工程共享。

pom.xml配置

首选,在pom文件中project标签下添加如下代码:

releases

Internal Releases

http://localhost:8081/nexus/content/repositories/thirdparty

releases

Internal Releases

http://localhost:8081/nexus/content/repositories/thirdparty

此时,执行deploy命令,会返回401错误,则需要用户验证或验证的信息有误。

setting.xml文件配置

在setting配置文件的servers标签下添加如下代码:

releases

admin

admin

PS:其中此处的id,必须为pom文件中配置的repository的id。

注意事项

一般继承 parent 的version会按照如下格式写:

module.some

module_parent

${parent.version}

这样写方便统一管理版本信息,但发布到maven私服之后,maven 会试图- module_parent 的 ${parent.version} 的 jar。显然,这个jar是不存在的。那么为什么已经指定了 parent.version 的值了却没有解析呢?这是因为deploy 的过程中,parent 标签里的变量是不会解析的,必须是一个常量。

结果

执行maven deploy命令成功之后,登录私服进行查询,即可看到对应的jar包。

maven deploy命令打包到私服

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.zeelan.app

seller-auth

0.0.1-SNAPSHOT

jar

UTF-8

1.16.10

1.2.17.2

5.1.2.Final

1.1.0.Final

nexus

Team Nexus Repository

http://192.168.0.126:8081/nexus/content/groups/public

releases

Nexus Release Repository

http://192.168.0.126:8081/nexus/content/repositories/releases/

snapshots

Nexus Snapshot Repository

http://192.168.0.126:8081/nexus/content/repositories/snapshots/

org.projectlombok

lombok

${lombok.version}

com.github.miemiedev

mybatis-paginator

${mybatis.paginator.version}

org.hibernate

hibernate-validator

${hibernate.validator.version}

javax.validation

validation-api

${validation.api.version}

seller-auth

maven-compiler-plugin

true

1.8

1.8

http://

maven-source-plugin

2.1

true

compile

jar

maven-deploy-plugin

2.7

default-deploy

deploy

deploy

true

deploy-file

deploy

deploy-file

${project.distributionManagement.snapshotRepository.id}

${project.distributionManagement.snapshotRepository.url}

${project.build.directory}/${project.artifactId}.jar

${project.groupId}

${project.artifactId}

${project.version}

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.zeelan.app

seller-auth

0.0.1-SNAPSHOT

jar

UTF-8

1.16.10

1.2.17.2

5.1.2.Final

1.1.0.Final

nexus

Team Nexus Repository

http://192.168.0.126:8081/nexus/content/groups/public

releases

Nexus Release Repository

http://192.168.0.126:8081/nexus/content/repositories/releases/

snapshots

Nexus Snapshot Repository

http://192.168.0.126:8081/nexus/content/repositories/snapshots/

org.projectlombok

lombok

${lombok.version}

com.github.miemiedev

mybatis-paginator

${mybatis.paginator.version}

org.hibernate

hibernate-validator

${hibernate.validator.version}

javax.validation

validation-api

${validation.api.version}

seller-auth

maven-compiler-plugin

true

1.8

1.8

http://

maven-source-plugin

2.1

true

compile

jar

maven-deploy-plugin

2.7

default-deploy

deploy

deploy

true

deploy-file

deploy

deploy-file

${project.distributionManagement.snapshotRepository.id}

${project.distributionManagement.snapshotRepository.url}

${project.build.directory}/${project.artifactId}.jar

${project.groupId}

${project.artifactId}

${project.version}

执行 mvn deploy就能打包到私服上了!

mvn -clean配置清除插件,然后在执行命令可以清除target下的文件

mvn-clean package 本地打包,jar/war/等根据jar/war控制

mvn -e 查看打包过程的错误信息

mvn -v查看mavne版本信息等等

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:通过Maven进行jedis连接redis的实现
下一篇:idea+maven打jar包的两种方式
相关文章

 发表评论

暂时没有评论,来抢沙发吧~