我正在开发小型Spring Boot微服务应用程序。当我试图创建自定义Spring映像部署到Docker引擎时,我面临着一个问题。为了创建新的自定义图像,我在POM文件的Maven插件部分使用配置元素。
错误:执行目标失败org.springframework.boot: spring-boot-maven-plugin: 2.5.5:构建过程(default-cli)在项目BankModule上:执行目标的default-cliorg.springframework.boot: spring-boot-maven-plugin: 2.5.5:构建过程失败:无法解析图像引用"kolludocker/ms1-BankModule: 0.0.1-SNAPSHOT"。图像参考必须是格式为'[domainHost:port/][path/]name[:tag][@digest]',其中包含'path'和'name'只包含[a-z0-9]。][_][-] -& gt;[帮助1](错误)
pom.xml
文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.kollu.BankModule</groupId>
<artifactId>BankModule</artifactId>
<version>0.0.1-SNAPSHOT
</version>
<name>BankModule</name>
<description>BankModule SpringBoot and MicroServices project
</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>2020.0.4</spring-cloud.version> <!-- Eureka server -->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Eureka server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency> <!-- Inbuild LoadBalancer dependency-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!-- Fault tolerance- Circuit Breakers with resilience4j -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
</dependency>
<!-- Distributed Tracing(To generate unique id per each logger) - sleuth,RabbitMQ,ZipKin --> <!-- <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-sleuth</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-sleuth-zipkin</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency> -->
<!-- mvnrepository.com/artifact/org.springframework.boot/… -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Oracle -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId> <!-- <scope>12.2.0.1</scope> -->
<version>12.2.0.1</version><!--$NO-MVN-MAN-VER$-->
</dependency> <!-- Swagger api -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<!-- Field/ Input values validation -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies> <!-- Eureka server -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.5</version><!--$NO-MVN-MAN-VER$-->
<configuration>
<image>
<name>kolludocker/ms1-${project.artifactId}:${project.version}</name>
</image>
<pullPolicy>IF_NOT_PRESENT</pullPolicy>
</configuration>
</plugin>
</plugins>
</build>
</project>
工件id的名称中有大写字母。给出的错误告诉我们:
只包含[a-z0-9][.][_][-]
的'path'和'name'
创建工件id "BankModule"对于"bank-module",这将工作。
您是否尝试过将小写字母设置为属性?这对我(v2.6.3)来说很好,而且在我看来更优雅/紧凑:
<properties>
<spring-boot.build-image.imageName>io.bla/example/bla</spring-boot.build-image.imageName>
</properties>
文档:https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/build-image.customization