尝试执行此代码时出现以下错误。
java.lang.IllegalArgumentException:在“ com.app.AggregatorAppAConfiguration”上找不到ConfigurationProperties批注。在org.springframework.util.Assert.notNull(Assert.java:115)〜[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]在org.springframework.boot.context.properties.EnableConfigurationPropertiesImportSelector $ ConfigurationPropertiesBeanRegistrar.registerBeanDefinition(EnableConfigurationPropertiesImportSelector.java:117)〜[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
想知道这里做错了什么
@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();
}
}
@chrylis。谢谢,此问题已通过删除@SpringBootApplication得以解决,并且由于无法找到Bean验证提供程序而无法创建配置。将诸如Hibernate Validator(RI)之类的提供程序添加到您的类路径中
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句