簡體   English   中英

spring boot + apache camel + mongodb集成問題

[英]spring boot + apache camel + mongodb integration issue

剛開始,我是apache camel的新手。 我有一個spring boot(MVC)+ mongodb項目已經運行正常,當我嘗試將它與apache camel集成時,我在控制台上遇到異常。 根據我對異常彈簧引導的理解,試圖說當我在項目的其他任何地方使用@ComponentScan(basePackages="packagePath")時,我無法在camel Route文件上使用默認注釋@Component ,因為它是一個MVC架構,我有控制器,服務和存儲庫,我不能忽視,請幫我解決這個問題。

控制台例外

啟動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)〜[s pring-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 :org.springframework上的org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]的:5.0.4.RELEASE] .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] 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 .RELEASE] ...省略了18個常見幀引起:java.lang.ClassNotFoundException:org.springframework.boot.bind.RelaxedPropertyResolver at 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>

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已在春季啟動(2.0.0.RELEASE)的最新版本中刪除。 但是,最新的camel-spring-boot-starter模塊(寫入時為2.20.2)仍取決於缺少的RelaxedPropertyResolver。

要解決此問題,直到有新版本的Camel,您需要將spring-boot降級為1.5.10.RELEASE。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM