0

这是我拥有的 Maven 依赖项

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.10.RELEASE</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
  </dependencies>

我想要实现的是,将弹簧芯从 4.3.14.RELEASE 更改为 4.3.4.RELEASE。是的,默认情况下,spring boot starter 使用的是 spring core 4.3.14,它可以扩展到 5.0.7.RELEASE,因为我尝试排除 spring-core 并包括 4.3.4.RELEASE

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.10.RELEASE</version>
            <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
            </exclusions>
                <scope>import</scope>
            <type>pom</type>
        </dependency>
       <dependency>
               <groupId>org.springframework</groupId>
               <artifactId>spring-core</artifactId>
               <version>4.3.4.RELEASE</version>
      </dependency>
</dependencies>

当我尝试构建它时,会引发以下期望

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Unsatisfied dependency expressed through method 'setFilterChainProxySecurityConfigurer' parameter 1; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.convert.support.DefaultConversionService.getSharedInstance()Lorg/springframework/core/convert/ConversionService;

手动添加每个依赖项是不可能的,因为应用程序使用了大量的依赖项,并且与其他依赖项的兼容性将是另一项艰巨的工作。

那么有什么解决方法吗?

注意:- 尝试使用 spring framework-bom 和 spring IO,但没有找到任何解决方案,也许我错过了一些东西。这些例子是受欢迎的。

4

1 回答 1

0

你真的不应该这样做。Spring Framework > Spring Boot > Spring Cloud > Data Flow 管理这些依赖项都是有原因的。您应该让 spring 处理依赖关系并根据需要升级您的实现。

https://spring.io/blog/2016/04/13/overriding-dependency-versions-with-spring-boot

更详细地回答这个问题。

想要这样做是合理的,但应该谨慎行事,因为新版本的传递依赖很容易破坏 Spring Boot 中依赖于旧版本的特性。当您这样做并应用以下修复程序之一时,您将自己从 Spring Boot 的依赖管理中分离出来并说“嘿,我知道我在做什么,相信我。” 不幸的是,有时您需要这样做才能利用第三方库中的新功能。如果您不需要新版本的 Reactor(或您需要的任何其他外部传递依赖项),那么不要这样做,只要坚持快乐的道路,让 Spring Boot 管理依赖项即可。

于 2018-07-06T12:24:14.113 回答