No Bean Found in Spring Boot application context

praneet drolia
@Data
@AllArgsConstructor
@NoArgsConstructor
@Component
@Configuration
@ConfigurationProperties("promotion")
public class PromotionConfig {
    private AppClientConfig appConfig;
}


@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AppClientConfig {
   private int readTImeout;
   private int writeTimeout;
}

When I am trying to do @Autowire PromotionConfig It is throwing an error that No Qualifying bean found for AppClientConfig.

I know this error is coming up because I dont have @Component in AppClientConfig.

How can i make it work without adding @Component in AppClientConfig. I want to keep it Plain POJO class.

My local.yml file

promotion:
  appConfig:
    readTImeout: 10
    writeTimeout: 10
user7294900

You can load statically the spring bean in non spring classes as:

PromotionConfig PromotionConfig = ApplicationInitializer.getAppContext().getBean(PromotionConfig.class);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Registered RendezvousChannel bean cannot be found within Spring Application Context

Spring Application context not found

Spring Boot application failed to start, bean could not be found

Spring Boot Bean could not be found

Spring Boot: class with @Service bean bean not found

Spring boot and Spring data no bean found entityMangerFactory

What is Application context and bean factory in spring framework

Kotlin Spring cannot register bean in application context

Spring bean dependencies in the application context form a cycle

Spring Boot Application 404 Not Found

Spring boot basic application: field NotesRepository required a bean of type 'com.demo.NotesRepository' that could not be found

Spring boot app failed to start with error "Application required a single bean, but 2 were found"

Spring Boot 2.1 EntityManagerFactory Bean could not be found

Why is bean not found during Spring Boot?

could not found bean for MongoRepository (Spring Boot)

Spring-boot:bean could not be found

Mapstruct + Lombok with Gradle in Spring Boot (Bean Not Found)

Spring Boot & MariaDB - Autowiring Problem - Bean not found

why the model bean is not found in the spring boot app?

Basic Spring JDBC application, JdbcTemplate bean not found

Spring integration test with context hierarchy child context bean as application listener

Spring Boot application-The bean could not be registered

Spring Boot application-The bean could not be registered

creating bean of a class in Spring Boot application?

Bean validation fails for Spring Boot application

spring boot application not working bean error

Adding inner bean to Application Context throws No default constructor found execption

Spring Boot: pruning application context for integration testing

What is a default Spring Boot Application Context?