简体   繁体   中英

SpringBoot No ConfigurationProperties annotation found

I am getting the following error while trying to execute this code.

java.lang.IllegalArgumentException: No ConfigurationProperties annotation found on 'com.app.AggregatorAppAConfiguration'. at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.boot.context.properties.EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.registerBeanDefinition(EnableConfigurationPropertiesImportSelector.java:117) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]

Wondering what is done wrong here

   @Component
public class AggregatorApp 
{
    private static final Logger logger = LoggerFactory.getLogger(AggregatorApp.class);

    public static void main( String[] args )
    {


        logger.info("good");
        SpringApplication app = new SpringApplication(AggregatorAppAConfiguration.class);
        app.setWebEnvironment(false);

        ConfigurableApplicationContext ctx = app.run(args);

        ctx.getBean(AggregatorApp.class).run();

    }

    public void run() {
        aggManager.start();
        System.out.println("Hello World !!");
    }
}



@Service
public class AggregatorManager {

    public void start() {
        System.out.println("Hello World");
    }
}


@Configuration
@ComponentScan("com.app.aggregator")
@EnableConfigurationProperties(AggregatorAppAConfiguration.class)
@EnableAutoConfiguration
public class AggregatorAppAConfiguration {

    @Bean
    public AggregatorManager aggregatorManager()
    {
        return new AggregatorManager();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM