您当前的位置:首页 > 学海无涯 > 心得笔记网站首页心得笔记
Java Maven编译使用Harbor
发布时间:2019-09-18作者:♂逸風★淩軒
Maven配置
修改setting.xml
1、servers中添加如下代码:
<server> <id>harbor</id> <username>admin</username> <password>a040706!A</password> </server>
2、pluginGroups中添加如下代码:
<pluginGroup>com.spotify</pluginGroup>
3、mirrors加入阿里云仓
<mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
项目配置
1、配置pom.xml
<properties> <docker.serverId>harbor</docker.serverId> <docker.registry.url>192.168.8.216:1180</docker.registry.url> <docker.plugin.version>1.2.0</docker.plugin.version> </properties> <build>
2、配置编译处pom.xml
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<dockerHost>${docker.registry.host}</dockerHost>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<registryUrl>${docker.registry.url}</registryUrl>
<serverId>${docker.serverId}</serverId>
<pushImage>true</pushImage>
</configuration>
</plugin>
</plugins>
2、测试发布
# mvn clean package docker:build
关键字词:Maven,Harbor

下一篇:Linux常用命令