spring boot 应用发布到Harbor上

具体的harbor配置和docker配置可以查看前面几篇,也包含了我遇到的问题

settings.xml配置

<server>
      <id>docker-hub</id>
      <username>admin</username>
      <password>Harbor12345</password>
    </server>

pom.xml配置

</parent>
        <groupId>com.topcheer</groupId>
        <artifactId>docker</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>docker</name>
        <description>Demo project for Spring Boot</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <docker.image.prefix>topcheer</docker.image.prefix>
        <docker.repostory>192.168.180.105:1180</docker.repostory>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>

      <build>
        <finalName>docker</finalName>
        <plugins>
            <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
           <!--加入下面两项配置-->
           <executions>
             <execution>
               <goals>
                 <goal>repackage</goal>
               </goals>
             </execution>
           </executions>
            <configuration>
                 <includeSystemScope>true</includeSystemScope>
            </configuration>
      </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.2.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                   </execution>
                    <execution>
                        <id>tag-image</id>
                        <phase>package</phase>
                        <goals>
                            <goal>tag</goal>
                        </goals>
                        <configuration>
                            <image>${docker.repostory}/${docker.image.prefix}/${project.artifactId}:1.0.1</image>
                            <newName>${docker.repostory}/${docker.image.prefix}/${project.artifactId}:1.0.1</newName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>push-image</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>push</goal>
                        </goals>
                        <configuration>
                            <imageName>${docker.repostory}/${docker.image.prefix}/${project.artifactId}:1.0.1</imageName>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <serverId>docker-hub</serverId>
                    <registryUrl>${docker.repostory}</registryUrl>
                    <dockerHost>http://192.168.180.105:2375</dockerHost>
                    <forceTags>true</forceTags>
                    <pushImage>true</pushImage>
                    <dockerDirectory>src/main/docker</dockerDirectory>
                    <imageName>${docker.repostory}/${docker.image.prefix}/${project.artifactId}:1.0.1</imageName>
                    <imageTags>
                        <imageTag>1.0.2</imageTag>
                    </imageTags>
                    <resources>
                        <rescource>
                            <targetPath></targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </rescource>
                    </resources>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>
        </plugins>
    </build>

运行命令

clean package docker:build -DpushImage -Dmaven.test.skip=true

原文地址:https://www.cnblogs.com/dalianpai/p/11811812.html

时间: 2024-08-29 03:03:04

spring boot 应用发布到Harbor上的相关文章

Spring Boot工程发布到Docker

先聊聊闲话 搞过企业级的application运维的同仁肯定深有感触,每个application的功能交叉错杂,数据交换就让人焦头烂额(当然这和顶层业务设计有关系), 几十个application发布,代码修改,打包,发布,再上dev/staging/prod三个代码版本,时刻要保证他们三个的环境依赖一致,比如jdk,webserver,appserver,安全设置,数据库等, 不然就导致程序跑不起来. 另一个问题,企业通常会按照功能将webserver,appserver,dbserver,f

Spring Boot+BootStrap fileInput 多图片上传

一.依赖文件 <link rel="stylesheet" type="text/css" th:href="@{/js/bootstrap/css/bootstrap.css}"> <link rel="stylesheet" type="text/css" th:href="@{/js/bootstrap/fileinput/css/fileinput.css}"&

Spring Boot 2.X 实现文件上传(三)

使用 SpringBoot 项目完成单个.多个文件的上传处理,并将上传的文件保存到指定目录下. 代码演示案例 所有的 HTML 页面文件 index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>选择上传文件类型</title> </head> <script languag

企业级 Spring Boot 教程 (十七)上传文件

这篇文章主要介绍,如何在springboot工程作为服务器,去接收通过http 上传的multi-file的文件. 构建工程 为例创建一个springmvc工程你需要spring-boot-starter-thymeleaf和 spring-boot-starter-web的起步依赖.为例能够上传文件在服务器,你需要在web.xml中加入标签做相关的配置,但在sringboot 工程中,它已经为你自动做了,所以不需要你做任何的配置. <dependencies> <dependency&

spring boot 事件发布与接收

1.创建发布对象 LoginEvent 2.在要发布对象的地方注入 ApplicationEventPublisher @Autowired ApplicationEventPublisher publisher; 3.发布 : 调用publisher的publishEvent(Object event)方法 publisher.publishEvent(new LoginEvent()) 4.创建事件监听Component @Component public class LoginEventH

【重磅】Spring Boot 2.1.0 权威发布

如果这两天登录 https://start.spring.io/ 就会发现,Spring Boot 默认版本已经升到了 2.1.0.这是因为 Spring Boot 刚刚发布了 2.1.0 版本,我们来看下 Spring Boot 2 发布以来第一个子版本都发布了哪些内容? 2.1 中的新特性 将spring-boot-starter-oauth2-oidc-client重命名为spring-boot-starter-oauth2-client命名更简洁 添加 OAuth2 资源服务 start

Spring Boot 使用 ServletFileUpload上传文件失败,upload.parseRequest(request)为空

使用Apache Commons FileUpload组件上传文件时总是返回null,调试发现ServletFileUpload对象为空,在Spring Boot中有默认的文件上传组件,在使用ServletFileUpload时需要关闭Spring Boot的默认配置 , 禁用MultipartResolverSpring提供的默认值 1.0在配置文件中添加 spring.http.multipart.enabled=false 2.0在配置文件中添加 spring.servlet.multip

Spring Boot干货系列:(二)配置文件解析

Spring Boot:配置文件解析   前言 上一篇介绍了Spring Boot的入门,知道了Spring Boot使用"习惯优于配置"(项目中存在大量的配置,此外还内置了一个习惯性的配置,让你无需手动进行配置)的理念让你的项目快速运行起来.所以,我们要想把Spring Boot玩的溜,就要懂得如何开启各个功能模块的默认配置,这就需要了解Spring Boot的配置文件application.properties. 正文 Spring Boot使用了一个全局的配置文件applicat

阿里P9告诉你 Spring Boot 2.0正式发布,升还是不升呢?

Spring帝国Spring几乎是每一位Java开发人员都耳熟能详的开发框架,不论您是一名初出茅庐的程序员还是经验丰富的老司机,都会对其有一定的了解或使用经验.在现代企业级应用架构中,Spring技术栈几乎成为了Java语言的代名词,那么Spring为什么能够在众多开源框架中脱颖而出,成为业内一致认可的技术解决方案呢?我们不妨从最初的Spring Framework开始,看看它为什么能够横扫千军,一统江湖! 挑战权威,一战成名 2004年3月,Spring的第一个版本以及其创始人Rod John