Spring Boot 2.2.0和Maven插件出现问题

Mag*_*o C 4 maven spring-boot

我有两个项目。一项如下(例如项目1):

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/> 
</parent>
Run Code Online (Sandbox Code Playgroud)

第二个(例如项目2)如下:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.0.BUILD-SNAPSHOT</version>
    <relativePath/> 
</parent>
Run Code Online (Sandbox Code Playgroud)

两者都有:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

好吧,项目1运行正常。我可以在我的.M2 repo文件夹中看到Spring Plugin 2.0.0.BUILD-SNAPSHOT。

项目2引发以下错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call the method org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin; but it does not exist. Its class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

    jar:file:/.../.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.BUILD-SNAPSHOT/spring-plugin-core-2.0.0.BUILD-SNAPSHOT.jar!/org/springframework/plugin/core/PluginRegistry.class

It was loaded from the following location:

    file:/.../.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.BUILD-SNAPSHOT/spring-plugin-core-2.0.0.BUILD-SNAPSHOT.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry
Run Code Online (Sandbox Code Playgroud)

当我尝试在项目2 POM中将版本强制为Maven插件时,我看到经典的黄色警告说我正在覆盖托管版本2.2.0.BUILD-SNAPSHOT,但是Maven插件没有2.2.0版本。

奇怪的是,我能够运行这个项目直到昨天。

有人可以告诉我怎么了吗?

注意:当我将项目2降级到2.0.3.RELEASE时,所有功能都开始工作。

pav*_*mar 6

此问题的解决方案很简单,您可以在依赖项部分导入Spring Boot Data REST Starter依赖项。只需删除它。一切都会好起来的,绝对完美。谢谢你!

  • 如果我真的需要 `spring-boot-starter-data-rest` 那么你的建议是什么? (2认同)

Mur*_*cha 5

当我们在项目中使用任何依赖项(提供的Spring Boot除外)时,我们需要提供Spring事务核心插件来解决此问题。

请尝试以下依赖项,并且版本与您的Spring Boot版本兼容。

春季交易核心依赖性:

<dependency>
        <groupId>org.springframework.plugin</groupId>
        <artifactId>spring-plugin-core</artifactId>
        <version>1.2.0.RELEASE</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)