gpt4 book ai didi

java - 组件需要名为 'org.springframework.boot.context.internalConfigurationPropertiesBinder' 的 bean,但无法找到

转载 作者:行者123 更新时间:2023-12-01 17:56:54 26 4
gpt4 key购买 nike

我有一个带有 Gradle 的 Spring Boot 多模块项目。运行应用程序时,我收到以下错误:-

Description:

A component required a bean named 'org.springframework.boot.context.internalConfigurationPropertiesBinder' that could not be found.


Action:

Consider defining a bean named 'org.springframework.boot.context.internalConfigurationPropertiesBinder' in your configuration.

该项目有一个根项目,该项目有一个子项目“GetAssociationService”

根项目 - build.gradle

    plugins {
id 'org.springframework.boot' version '2.2.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'com.github.johnrengelman.shadow' version '5.2.0'
}

bootJar { enabled = false }

jar { enabled = true }

subprojects {
group = 'org.qmetech'
version = '1.0.0'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
}

repositories { mavenCentral ( ) }

ext { set ( 'springCloudVersion' , "Hoxton.SR3" ) }

dependencies {
testImplementation ( 'org.springframework.boot:spring-boot-starter-test' ) {
exclude group: 'org.junit.vintage' , module: 'junit-vintage-engine'
}
}

ext.libraries = [
commonlibraries: [ 'org.springframework.boot:spring-boot-starter:2.2.5.RELEASE' ,
'org.springframework.cloud:spring-cloud-function-context' ,
'org.springframework.cloud:spring-cloud-function-adapter-aws:2.0.1.RELEASE' ,
'com.amazonaws:aws-lambda-java-log4j:1.0.0' ,
'org.springframework.boot:spring-boot-starter-web:2.2.5.RELEASE' ,
'org.springframework.cloud:spring-cloud-starter-function-web:1.0.0.RELEASE' ,
'org.springframework.boot.experimental:spring-boot-thin-layout:1.0.11.RELEASE' ,
'org.springframework.boot:spring-boot-starter-data-mongodb:2.2.5.RELEASE',
'org.springframework.cloud:spring-cloud-function-compiler:2.0.0.RELEASE'] ,
]

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

test { useJUnitPlatform ( ) }
ChildProject - build.gradle

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}

springBoot {
mainClassName = 'org.qmetech.GetAssociationService'
}

dependencies {
dependencies {
compile libraries.commonlibraries
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
}
}

UserRepository.java

package org.qmetech.repository;

import org.qmetech.domain.User;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends MongoRepository<User, Integer> { }

AssociationService.java

package org.qmetech.service;

import org.qmetech.domain.User;
import org.qmetech.repository.UserRepository;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.function.Function;

@Component
public class AssociationService implements Function<String, List<User>> {

private final UserRepository userRepository;

public AssociationService(UserRepository userRepository) {
this.userRepository = userRepository;
}

@Override
public List<User> apply(String uppercaseRequest) {
List<User> users = userRepository.findAll();
return users;
}
}

完整的代码可以在这里找到 - https://github.com/iftekharkhan09/Services

谁能告诉我我做错了什么吗?

谢谢!

最佳答案

我也遇到了这个问题,就我而言,“org.springframework.boot”版本中存在问题。我将版本更改为 2.1.6 Release。然后问题就解决了。

关于java - 组件需要名为 'org.springframework.boot.context.internalConfigurationPropertiesBinder' 的 bean,但无法找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60696841/

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