首先创建一个Dockerfile

编写Dockerfile的信息
FROM java:8
MAINTAINER clarkshi@xxx.com
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ENV ACTIVE="pre"
ENV loggingpath="/zhibo/logs"
ADD target/ShuZiZhiBo-0.0.1.jar ShuZiZhiBo.jar
ENTRYPOINT ["java" ,"-Dspring.profiles.active=${ACTIVE}","-Dlogging.path=${loggingpath}", "-jar","/ShuZiZhiBo.jar"]
ENV ACTIVE="pre"设置推送的环境
ENV loggingpath设置生成的日志
登陆腾讯云 镜像仓库,创建一个镜像地址


创建后,记住【仓库地址】和【命名空间】
pom文件编辑(这里需提前创建访问凭证)
<plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.4.13</version> <executions> <execution> <id>harbor</id> <goals> <goal>build</goal> <goal>push</goal> </goals> </execution> </executions> <configuration> <!-- 腾讯云镜像仓库地址 --> <!-- <repository>仓库地址预发布环境</repository>--> <!-- <repository>仓库地址正式环境</repository>--> <repository>仓库地址-测试环境</repository> <tag>${project.version}</tag> <useMavenSettingsForAuth>true</useMavenSettingsForAuth> <!-- 构建的用户凭证 --> <username>10002我删除了一半</username> <password>eyxxxxx我删除了一大坨/password> <buildArgs> <!-- 构建的jar包文件名 --> <JAR_FILE>${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </plugin>然后打开右边的maven点击plugins里面的dockerfile,选择build和push就能自动推送了

















![推荐一款神级编程工具[Cursor]自带gpt而且免费!](https://img-blog.csdnimg.cn/img_convert/42ba072cfcb3b08e0fe2ea4d5a78e5f9.png)

