Spring Boot + Apache骆驼+ MongoDB集成问题 [英] spring boot + apache camel + mongodb integration issue

查看:101
本文介绍了Spring Boot + Apache骆驼+ MongoDB集成问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是刚接触阿帕奇骆驼的人.我有一个Spring Boot(MVC)+ mongodb项目已经运行良好,当我尝试将其与apache camel集成时,控制台上出现异常.据我对异常启动的理解,Spring Boot试图说,当我在项目中的其他任何地方使用@ComponentScan(basePackages="packagePath")时,我无法在骆驼路径文件上使用默认注释@Component,因为它是MVC架构,所以我有Controller &我不能忽略的存储库,请帮助我解决此问题.

I am new to apache camel, just started. I have a spring boot (MVC) + mongodb project already running fine, when I am trying to integrate it with apache camel I am getting exception on console. As per my understanding on exception spring boot is trying to say that I cannot use default annotaion @Component on camel Route file when I am using @ComponentScan(basePackages="packagePath") anywhere else in the project, since it is a MVC architecture, I have Controller, Service & Repository which I cannot ignore, please help me solve this issue.

控制台异常

启动ApplicationContext时出错.显示条件报告 在启用调试"的情况下重新运行您的应用程序. 2018-03-15 17:17:55.426 错误744 --- [main] o.s.boot.SpringApplication
:应用程序运行失败

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2018-03-15 17:17:55.426 ERROR 744 --- [ main] o.s.boot.SpringApplication
: Application run failed

org.springframework.beans.factory.BeanDefinitionStoreException:失败 处理配置类的导入候选 [com.era.conf.ApplicationConfiguration];嵌套的异常是 java.lang.IllegalStateException:无法评估条件 org.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration 由于org/springframework/boot/bind/RelaxedPropertyResolver不存在 成立.确保您自己的配置不依赖该类. 如果您使用@ComponentScanning springframework,也会发生这种情况 软件包(例如,如果您将@ComponentScan放在默认软件包中,则 错误) org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616) 〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]在 org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:548) 〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]在 org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) 〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]在 org.springframework.context.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]在 org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) 〜[spring-context-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-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]位于 org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]位于 org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]位于 org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]位于 org.springframework.boot.SpringApplication.run(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.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration 由于org/springframework/boot/bind/RelaxedPropertyResolver不存在 成立.确保您自己的配置不依赖该类. 如果您使用@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) 〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]在 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/springframework/boot/bind/RelaxedPropertyResolver位于 org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator.isEnabled(HierarchicalPropertiesEvaluator.java:49) 〜[camel-spring-boot-2.20.2.jar:2.20.2]在 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.RELEASE] ... 18 省略了常见的框架造成原因:java.lang.ClassNotFoundException: 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] 在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个共同的框架

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.era.conf.ApplicationConfiguration]; nested exception is java.lang.IllegalStateException: Could not evaluate condition on org.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake) at 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] at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at com.era.conf.ApplicationConfiguration.main(ApplicationConfiguration.java:12) [classes/:na] Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake) at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55) ~[spring-boot-autoconfigure-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:109) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at 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 common frames omitted Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver at org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator.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] at org.apache.camel.spring.boot.util.GroupCondition.getMatchOutcome(GroupCondition.java:40) ~[camel-spring-boot-2.20.2.jar:2.20.2] at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.0.0.RELEASE.jar:2.0.0.RELEASE] ... 18 common frames omitted Caused by: 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] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_102] ... 22 common frames omitted

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();
    }
}

服务

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");
    }
}

推荐答案

问题是 RelaxedPropertyResolver 已在最新版本的spring-boot(2.0.0.RELEASE)中删除.但是,最新的camel-spring-boot-starter模块(撰写本文时为2.20.2)仍然取决于缺少的RelaxedPropertyResolver.

The problem is that RelaxedPropertyResolver has been removed in the latest release of spring-boot (2.0.0.RELEASE). However, the latest camel-spring-boot-starter module (2.20.2 when writing this) still depends on the missing RelaxedPropertyResolver.

要解决此问题,直到发布新版本的Camel,您需要将spring-boot降级到1.5.10.RELEASE.

To solve the issue until there is a new version of Camel you need to downgrade spring-boot to 1.5.10.RELEASE.

这篇关于Spring Boot + Apache骆驼+ MongoDB集成问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆