gpt4 book ai didi

gradle - 如何使Spring Boot 2.x中的Spring数据库兼容?

转载 作者:行者123 更新时间:2023-12-03 03:56:07 25 4
gpt4 key购买 nike

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

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)配置是这样的:
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"

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

gradle build -x测试

最佳答案

您混合了由Spring Boot管理的依赖性和要显式管理的依赖性。这可能导致冲突,因此请尝试以下操作:

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依赖项,否则应尽可能使用启动器。

此外, org.springframework:springloaded已移至“阁楼”:
  • https://spring.io/projects(页面底部)
  • https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#hot-swapping

  • 请使用 spring-boot-devtools代替: https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-devtools`

    关于gradle - 如何使Spring Boot 2.x中的Spring数据库兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59564275/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com