Sha*_*mad 8 java spring-mvc apache-camel mongodb spring-boot
刚开始,我是apache camel的新手.我有一个spring boot(MVC)+ mongodb项目已经运行正常,当我尝试将它与apache camel集成时,我在控制台上遇到异常.根据我对异常弹簧启动的理解,@Component当我@ComponentScan(basePackages="packagePath")在项目中的其他任何地方使用时,我试图说我不能在camel Route文件上使用默认注释,因为它是一个MVC架构,我有Controller,Service&Repository,我不能忽视,请帮我解决这个问题.
控制台例外
启动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上的条件.确保您自己的配置不依赖于该类.(如果你把一个@ComponentScan在默认包错误EG)这也有可能发生,如果你是一个@ComponentScanning包springframework的在org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616)〜[弹簧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)〜[弹簧上下文5.0.4.RELEASE.jar:5.0.4.RELEASE]在org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java: 233)〜[s 普林-上下文5.0.4.RELEASE.jar:5.0.4.RELEASE]在org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)〜[弹簧上下文5.0.4.RELEASE.jar :5.0.4.RELEASE]在org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)〜[弹簧上下文5.0.4.RELEASE.jar:5.0.4.RELEASE]在org.springframework .context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)〜[弹簧上下文5.0.4.RELEASE.jar:5.0.4.RELEASE]在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext. java:531)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)~ [spring org.springfra中的-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] orwork.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)中的mework.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)〜[[]在org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:109)〜[spring-context-5.0.4.RELEASE]中的spring-boot-autoconfigure-2.0.0.RELEASE.jar:2.0.0.RELEASE .jar:5.0.4.RELEASE]在org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:217)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org .springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:606)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] ...省略了15个常见帧引起的:java.lang .NoClassDefFoundError:org.apache.camel.spring.boot.util.HierarchicalPropertiesEvalu中的org/springframework/boot/bind/RelaxedPropertyResolver ator.isEnabled(HierarchicalPropertiesEvaluator.java:49)〜[camel-spring-boot-2.20.2.jar:2.20.2] at org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator.evaluate(HierarchicalPropertiesEvaluator.java:42 )〜[camel-spring-boot-2.20.2.jar:2.20.2] org.apache.camel.spring.boot.util.GroupCondition.getMatchOutcome(GroupCondition.java:40)〜[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抛出java.lang.ClassNotFoundException:.RELEASE] ... 18个共同帧省略了致org.springframework.boot.bind.RelaxedPropertyResolver在java.net.URLClassLoader.findClass(URLClassLoader.java:381)〜[NA:1.8.0_102 ]在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] at at 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>
Run Code Online (Sandbox Code Playgroud)
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);
}
}
Run Code Online (Sandbox Code Playgroud)
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();
}
}
Run Code Online (Sandbox Code Playgroud)
服务
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);
}
}
Run Code Online (Sandbox Code Playgroud)
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");
}
}
Run Code Online (Sandbox Code Playgroud)
小智 15
问题是,RelaxedPropertyResolver已在春季启动(2.0.0.RELEASE)的最新版本中删除.但是,最新的camel-spring-boot-starter模块(写入时为2.20.2)仍取决于缺少的RelaxedPropertyResolver.
要解决此问题,直到有新版本的Camel,您需要将spring-boot降级为1.5.10.RELEASE.