最近要写一个基于springboot的三方sdk,供其他项目使用,所以需要了解怎么将springboot打成到 jar,并上传到私服,然后下载使用
打包上传
-
配置Maven settings.xml
<servers>
<server>
<id>cider</id>
<username>cider</username>
<password>123</password>
</server>
<server>
<id>cider</id>
<username>cider</username>
<password>123</password>
</server>
</servers>
-
springboot pom文件配置私服maven地址
<distributionManagement>
<repository>
<id>cider</id>
<name>release</name>
<url>http://127.0.0.1:8888/repository/cider/</url>
</repository>
<snapshotRepository>
<id>cider</id>
<name>snapshot</name>
<url>http://127.0.0.1:8888/repository/cider/</url>
</snapshotRepository>
</distributionManagement>
需要注意的是 name需要和 之前settings中配置的name一致
-
打包上传至私服maven
这里maven插件不使用springboot的,使用 apache
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
因为这里打包会运行 test报错,这里暂时不处理即可,所以直接设置直接跳过test
注意这里 打包方式使用jar,然后需要注意版本version不要带SNAPSHOT,不然会报错
400 Bad Request
如果还有问题检查下私服的配置这里Deployment Policy设置为Allow Redeploy而不是Disable Redeploy。
其他项目使用
-
配置私服 在pom中添加私服坐标
<repositories>
<repository>
<id>cider</id>
<name>cider</name>
<url>http://127.0.0.1:8888/repository/cider/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependency>
<groupId>com.cider</groupId>
<artifactId>monitor</artifactId>
<version>0.0.1</version>
</dependency>
原文始发于微信公众号(小奏技术):Springboot 打包jar并上传私服maven(Nexus3),下载使用
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/30491.html