试图从属性文件中读取版本,但低于异常
- 生命周期配置未涵盖插件执行:org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties (执行:默认,阶段:初始化)
- 缺少工件org.springframework.cloud:spring-cloud-starter-zipkin:jar:$ {zipkin-version}
下面是pom.xml
和properties
文件
<?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 https://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.3.0.RELEASE</version>
<relativePath />
</parent>
<groupId>com.wtw</groupId>
<artifactId>Demo Project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AlertNotification</name>
<description>Demo</description>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
<configuration>
<files>
<file>C:\Workspace\version.properties</file>
</files>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<version>${zipkin-version}</version>
</dependency>
</dependencies>
</project>
version.properties file
zipkin-version=2.2.2.RELEASE
答案 0 :(得分:3)
依赖关系在执行插件之前已解决。
因此您在<dependencies>
部分中看不到使用properties-maven-plugin读取的属性。
如果要通过属性设置依赖项版本,则必须在POM内部,命令行或settings.xml
中设置此属性。
答案 1 :(得分:-1)
您正在使用旧版本的插件(1.0-alpha-2
),请将其更新为latest 1.0.0
。
然后确保文件version.properties
在文件夹C:\Workspace
中。无论如何,使用最新版本的插件,如果找不到该文件,您应该得到一条正确的错误消息。
另一个建议:spring-cloud-starter-zipkin
属于org.springframework.cloud
组,该组遵循另一个版本。声明依赖关系的建议方法如下:
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR6</spring-cloud.version>
</properties>
<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>
<dependencies>
<!-- ... -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<!-- ... -->
</dependencies>