刚开始,我是apache camel的新手 . 我有一个spring boot(MVC)mongodb项目已经运行正常,当我尝试将它与apache camel集成时我在控制台上遇到异常 . 根据我对异常 spring 启动的理解,试图说当我在项目中的其他地方使用 @ComponentScan(basePackages="packagePath")
时,我无法在camel Route文件上使用默认注释 @Component
,因为它是MVC架构,我有Controller,Service&Repository我不能忽视,请帮我解决这个问题 .
Console Exception
启动ApplicationContext时出错 . 要显示条件报告,请在启用“debug”的情况下重新运行应用程序 . 2018-03-15 17:17:55.426 ERROR 744 --- [main] osboot.SpringApplication:应用程序运行失败org.springframework.beans.factory.BeanDefinitionStoreException:无法处理配置类的导入候选[com.era.conf .ApplicationConfiguration];嵌套异常是java.lang.IllegalStateException:由于未找到org / springframework / boot / bind / RelaxedPropertyResolver,无法评估org.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration上的条件 . 确保您自己的配置不依赖于该类 . 如果你是@ComponentScanning springframework包(例如,如果你错误地将@ComponentScan放在默认包中),org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616)〜[spring- context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:548)〜[spring-context-5.0.4.RELEASE.jar:5.0 .4.RELEASE]在org.springframework.context的org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] .annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java: 233)〜 [spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]在org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)〜[spring-context-5.0.4.RELEASE . jar:5.0.4.RELEASE] org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org . orframe.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext)中的springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] .java:531)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)~ [ org.springf上的spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] orme.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)中的ramework.boot.SpringApplication.refresh(SpringApplication.java:752)[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] org.springframework.boot.SpringApplication.run上的[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE](SpringApplication.java:327)[spring-boot-2.0.0.RELEASE.jar:2.0 .O.RELEASE] org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] org.springframework.boot.SpringApplication . 运行(SpringApplication.java:1234)[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE],位于com.era.conf.ApplicationConfiguration.main(ApplicationConfiguration.java:12)[classes /:na]引起:java.lang.IllegalStateException:由于未找到org / springframework / boot / bind / RelaxedPropertyResolver,无法评估org.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration上的条件 . 确保您自己的配置不依赖于该类 . 如果您是@ComponentScanning springframework包(例如,如果您错误地将@ComponentScan放在默认包中),也会发生这种情况 . org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55)〜[spring-boot-autoconfigure-2.0.0.RELEASE.jar:2.0.0.RELEASE] org.springframework.context.annotation .conditionEvaluator.shouldSkip(ConditionEvaluator.java:109)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:217) org.springframework.context.annotation.ConfigurationClassParser.processImports上的〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]〜[spring-context-5.0.4.RELEASE .jar:5.0.4.RELEASE] ...省略了15个常见帧引起:java.lang.NoClassDefFoundError:org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator.isEnabled中的org / springframework / boot / bind / RelaxedPropertyResolver (HierarchicalPropertiesEvaluator.java:49)〜[camel-spring-boot-2.20.2.jar:2.20.2]在org.apache.camel.spring.boot.util.HierarchicalPro在org.apache.camel.spring.boot.util.GroupCondition.getMatchOutcome(GroupCondition.java:40)的pertiesEvaluator.evaluate(HierarchicalPropertiesEvaluator.java:42)〜[camel-spring-boot-2.20.2.jar:2.20.2] )〜[camel-spring-boot-2.20.2.jar:2.20.2] org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)〜[spring-boot-autoconfigure-2.0 . 0.RELEASE.jar:2.0.0.RELEASE] ...省略了18个常见帧引起:java.lang.ClassNotFoundException:org.springframework.boot.bind.RelaxedPropertyResolver at java.net.URLClassLoader.findClass(URLClassLoader.java: 381)〜[na:1.8.0_102] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na:1.8.0_102] at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:331) 〜[na:1.8.0_102]在java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8.0_102] ...省略了22个常用帧
POM
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.20.2</version>
</dependency>
</dependencies>
ApplicationConfiguration
package com.era.conf;
@SpringBootApplication
@ComponentScan(basePackages = "com.era.controller")
public class ApplicationConfiguration {
public static void main(String[] args) throws Exception {
SpringApplication.run(ApplicationConfiguration.class, args);
}
}
EmailResponseController
package com.era.controller;
@RestController
@RequestMapping("/emailResponse")
@ComponentScan(basePackages = "com.era.service")
public class EmailResponseController {
@Autowired private EmailResponseService serv;
@RequestMapping("/read")
public EmailResponseModel ExchangeServerEmailsReader() {
return serv.ExchangeServerEmailsReader();
}
}
Service
package com.era.service;
@Service
@EnableMongoRepositories("com.era.repository")
public class EmailResponseServiceImpl implements EmailResponseService {
@Autowired private EmailResponseRepository repo;
@Override
public EmailResponseModel ExchangeServerEmailsReader() {
final EmailResponseModel emailModel = new EmailResponseModel();
emailModel.setEmail(readEmailsFromExchangeServer());
return repo.save(emailModel);
}
}
CamelRouteClass
package com.era.route;
@Component
public class CamelRouteClass extends RouteBuilder {
@Override
public void configure() throws Exception {
from("file:C://response?noop=true").to("file:C://response2");
}
}
1 回答
问题是在最新版本的spring-boot(2.0.0.RELEASE)中删除了 RelaxedPropertyResolver . 但是,最新的camel-spring-boot-starter模块(写入时为2.20.2)仍取决于缺少的RelaxedPropertyResolver .
要解决此问题,直到有新版本的Camel,您需要将spring-boot降级为1.5.10.RELEASE .