java Maven导入问题,在complie时间使用里程碑版本,但在运行时使用最新版本
我已经在RC
文件中声明了依赖项的POM.xm
版本。在编译时使用RC
版本,但在运行时使用RELEASE
版本,这会导致java.lang.NoSuchMethodError
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>4.1.0-RC1</version>
</dependency>
这会将4.1.0-RC1
和4.0.3.RELEASE
添加到类路径中
SearchHit#getIndex
在4.1.x
版本中引入,该版本仍处于里程碑阶段。以下是这个maven模块的完整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>
<artifactId>example-parent</artifactId>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>search</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>4.1.0-RC1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/libs-milestone</url>
</repository>
</repositories>
</project>
这是一个多模块spring boot项目,使用spring-boot-starter-parent
版本2.3.3.RELEASE
问题出在哪里?我正在使用Intellij IDEA
更新:
- 如果我从这个“搜索”模块中删除
spring-data-elasticsearch
,两个版本都会从项目中删除 - 我正在使用这个“搜索”模块进入“休息”模块。我运行了
mvn dependency:tree
,结果的日志令人惊讶。“search”模块有4.1.0-RC1
版本,但在“rest”模块中,“search”被导入,并且没有额外的elasticsearh依赖性出现4.0.3.RELEASE
李>
共 (0) 个答案