Springboot 打包jar并上传私服maven(Nexus3),下载使用

最近要写一个基于Springboot的三方sdk,供其他项目使用,所以需要了解怎么将SpringBoot打成 jar,并上传到私服,然后下载使用

打包上传

  1. 配置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>
  1. 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一致

  1. 打包上传至私服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>

然后跳过打包的testSpringboot 打包jar并上传私服maven(Nexus3),下载使用

因为这里打包会运行 test报错,这里暂时不处理即可,所以直接设置直接跳过test

Springboot 打包jar并上传私服maven(Nexus3),下载使用注意这里 打包方式使用jar,然后需要注意版本version不要带SNAPSHOT,不然会报错400 Bad Request如果还有问题检查下私服的配置Springboot 打包jar并上传私服maven(Nexus3),下载使用这里Deployment Policy设置为Allow Redeploy而不是Disable Redeploy。

上面都处理完,直接使用插件 deploy即可Springboot 打包jar并上传私服maven(Nexus3),下载使用

运行成功后我们可以去私服查看Springboot 打包jar并上传私服maven(Nexus3),下载使用依赖坐标在右边也有

其他项目使用

  1. 配置私服 在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

(0)
小半的头像小半

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!