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

huangapple 未分类评论47阅读模式
英文:

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

问题

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

描述:

某个组件需要一个名为'org.springframework.boot.context.internalConfigurationPropertiesBinder'的bean,但找不到该bean。

操作:

考虑在您的配置中定义一个名为'org.springframework.boot.context.internalConfigurationPropertiesBinder'的bean。

该项目有一个根项目,其中包含一个名为'GetAssociationService'的子项目。

rootproject - 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 {
    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

有人能告诉我我做错了什么吗?

谢谢!

英文:

I have a spring boot multi-module project with Gradle. While running the application i am getting the below error:-

Description:

A component required a bean named &#39;org.springframework.boot.context.internalConfigurationPropertiesBinder&#39; that could not be found.


Action:

Consider defining a bean named &#39;org.springframework.boot.context.internalConfigurationPropertiesBinder&#39; in your configuration.

The project has a root project which has a subproject 'GetAssociationService'

rootproject - build.gradle

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

bootJar { enabled = false }

jar { enabled = true }

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

repositories { mavenCentral ( ) }

ext { set ( &#39;springCloudVersion&#39; , &quot;Hoxton.SR3&quot; ) }

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

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

dependencyManagement {
    imports {
        mavenBom &quot;org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}&quot;
    }
}

test { useJUnitPlatform ( ) }
ChildProject - build.gradle

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

springBoot {
    mainClassName = &#39;org.qmetech.GetAssociationService&#39;
}

dependencies {
    dependencies {
        compile libraries.commonlibraries
        implementation &#39;org.springframework.boot:spring-boot-starter-data-mongodb&#39;
    }
}

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&lt;User, Integer&gt; { }

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&lt;String, List&lt;User&gt;&gt; {

    private final UserRepository userRepository;

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

    @Override
    public List&lt;User&gt; apply(String uppercaseRequest) {
        List&lt;User&gt; users = userRepository.findAll();
        return users;
    }
}

The Complete Code can be found here - https://github.com/iftekharkhan09/Services

Can Anyone please tell me what am I doing wrong?

Thanks!

答案1

得分: 0

我也遇到了这个问题,在我这个情况下,问题出在 'org.springframework.boot' 版本上。我把版本改成了 2.1.6 Release。然后问题解决了。

英文:

I also had this problem and in my case, there was the problem in 'org.springframework.boot' version. I changed my version to 2.1.6 Release. Then the problem resolved.

答案2

得分: 0

请验证您的pom.xml文件,并确保您正在使用与Spring Cloud相匹配的Spring Boot框架版本。

例如,对于Spring Cloud Greenwich,您将需要使用Spring Boot 2.1.x版本。

这是Spring Cloud的文档链接:https://spring.io/projects/spring-cloud
请查看章节:Release Trains

英文:

Please verify your pom.xml and make sure you are using the matching version of the Spring boot framework for Spring Cloud.

e.g. For Spring Cloud Greenwich you will need Spring boot 2.1.x

Here is Spring cloud documentation : https://spring.io/projects/spring-cloud
Revisit section : Release Trains

huangapple
  • 本文由 发表于 2020年3月16日 03:35:56
  • 转载请务必保留本文链接:https://java.coder-hub.com/60696841.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定