如何使Spring Boot 2.x中的Spring数据库兼容? [英] how to make spring data lib compatiable in spring boot 2.x?

查看:159
本文介绍了如何使Spring Boot 2.x中的Spring数据库兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用以下命令运行我的应用程序时:

when I run my app using:

java -jar soa-happy-rain-service-1.0.0-SNAPSHOT.jar

引发此错误:

 :: Spring Boot ::        (v2.2.2.RELEASE)

2020-01-02 21:20:52.817  INFO [soa-happy-rain-service,,,] 994 --- [           main] com.sportswin.soa.happy.rain.AppStarter  : No active profile set, falling back to default profiles: default
2020-01-02 21:20:55.478 ERROR [soa-happy-rain-service,,,] 994 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

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

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$AutoConfiguredAnnotationRepositoryConfigurationSource.<init>(AbstractRepositoryConfigurationSourceSupport.java:128)

The following method did not exist:

    org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;Lorg/springframework/beans/factory/support/BeanNameGenerator;)V

The method's class, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource, is available from the following locations:

    jar:file:/Users/dolphin/source/dabai/microservice/soa-happy-rain/soa-happy-rain-service/build/libs/soa-happy-rain-service-1.0.0-SNAPSHOT.jar!/BOOT-INF/lib/spring-data-commons-2.1.6.RELEASE.jar!/org/springframework/data/repository/config/AnnotationRepositoryConfigurationSource.class

It was loaded from the following location:

    jar:file:/Users/dolphin/source/dabai/microservice/soa-happy-rain/soa-happy-rain-service/build/libs/soa-happy-rain-service-1.0.0-SNAPSHOT.jar!/BOOT-INF/lib/spring-data-commons-2.1.6.RELEASE.jar!/


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource

我的gradle(6.0)配置如下:

my gradle(6.0) config like this:

id "org.springframework.boot" version "2.2.2.RELEASE"
apply plugin: 'org.springframework.boot'


implementation "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}"
       implementation "org.springframework.boot:spring-boot-starter-web"
        implementation "org.springframework.boot:spring-boot-starter-data-redis"
        implementation "org.springframework.boot:spring-boot-starter-cache"
        implementation "org.springframework:spring-aspects:${springVersion}"
        implementation "org.springframework:springloaded:1.2.8.RELEASE"
        implementation "org.springframework.boot:spring-boot-starter-test"
        implementation "org.springframework:spring-test:${springVersion}"
        implementation "org.springframework.boot:spring-boot-starter-actuator"

我已经在使用插件来管理依赖项了.如何找出哪里出了问题?我应该怎么做才能解决这个问题.这是我的项目构建命令:

I am already using plugin to manage the dependencies.How to find out where is gong wrong? what should I do to fix this.This is my project build command:

渐变构建-x测试

推荐答案

您混合了由Spring Boot 明确管理的依赖关系.这可能是造成冲突的原因,因此请尝试以下操作:

You have a mixture of dependencies managed by Spring Boot and dependencies you are explicitly managing. This may be causing the conflict, so try the following:

implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-data-redis"
implementation "org.springframework.boot:spring-boot-starter-cache"
implementation "org.springframework.boot:spring-boot-starter-aop"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-test"

除非您有理由包括各个Spring依赖项,否则请尽可能使用启动器.

Use the starters as much as possible unless you have a reason to include individual Spring dependencies.

此外, org.springframework:springloaded 已移至阁楼":

  • https://spring.io/projects (bottom of page)
  • https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#hot-swapping

改用 spring-boot-devtools : 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆