小编典典

Spring Boot + Apache camel+ MongoDB集成问题

spring-boot

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

控制台异常

启动ApplicationContext时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。2018-03-15
17:17:55.426错误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上的条件。确保您自己的配置不依赖该类。如果您正在org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616)上使用@ComponentScanning
springframework软件包(例如,如果错误地将@ComponentScan放入默认软件包),也会发生这种情况。
context-5.0.4.RELEASE.jar:5.0.4.RELEASE],位于org.springframework.context.annotation。IllegalStateException:由于找不到org
/ springframework / boot / bind /
RelaxedPropertyResolver,因此无法评估org.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration上的条件。确保您自己的配置不依赖该类。如果您正在org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55)上使用@ComponentScanning
springframework软件包(例如,如果错误地将@ComponentScan放入默认软件包),也会发生这种情况。 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。

聚甲醛

<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>

应用配置

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

阅读 557

收藏
2020-05-30

共1个答案

小编典典

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

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

2020-05-30