【问题标题】:Spring Boot 2.2.0 and Maven Plugin troubleSpring Boot 2.2.0 和 Maven 插件的麻烦
【发布时间】:2019-07-12 22:29:19
【问题描述】:

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

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/> 
</parent>

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

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.0.BUILD-SNAPSHOT</version>
    <relativePath/> 
</parent>

两者都有这个:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

嗯,项目 1 运行良好。我可以在我的 .M2 存储库文件夹中看到 Spring Plugin v. 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

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

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

谁能告诉我出了什么问题?

注意:当我将项目 2 降级到 2.0.3.RELEASE 时,一切都开始工作了。

【问题讨论】:

  • 您使用-SNAPSHOT 版本有什么原因吗?
  • 其实没有原因。我必须使用 v2.1.3 吗?
  • 我会使用发布版本而不是-SNAPSHOT,只有当你尝试特殊的东西时。所以我建议使用最新的发布版本,即 2.1.3
  • 如果是这样,我必须认为这是一个冷案。你统治!
  • 也许我误解了你的回答。如果不升级,这取决于您是否必须坚持使用 2.0.X 线...

标签: maven spring-boot


【解决方案1】:

这个问题的解决方法很简单,你可以在你的依赖部分导入Spring Boot Data REST Starter依赖。只需将其删除。一切都会正常工作,绝对完美。谢谢!

【讨论】:

  • 我不知道您是如何得出这个结论的以及为什么。
  • 如果我真的需要spring-boot-starter-data-rest那么你有什么建议?
  • 这是真正的罪魁祸首。没有别的像弹簧芯,招摇等只是这个。谢谢
  • 没有依赖,我无法解析 RepositoryEventHandler 类。
【解决方案2】:

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

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

Spring 事务核心依赖:

<dependency>
        <groupId>org.springframework.plugin</groupId>
        <artifactId>spring-plugin-core</artifactId>
        <version>1.2.0.RELEASE</version>
    </dependency>

【讨论】:

  • spring-plugin-core 的使命(功能)是什么?我不清楚。你能再解释一下吗?我只是复制/过去的代码 sn-ps 不太舒服。 @khmarbaise 降级评论实际上解决了这个问题。
  • 您的答案可能是正确的,只是因为赞成票,我很想接受它,但我还没有实际测试过,因为它已经通过将版本保持在重新发布的行中避免触摸快照来解决。跨度>
猜你喜欢
  • 2014-06-20
  • 2017-03-26
  • 1970-01-01
  • 2015-02-04
  • 2011-11-22
  • 2018-01-07
  • 2018-01-07
  • 1970-01-01
  • 2017-03-01
相关资源
最近更新 更多