Camel Java DSL:无法解析bean定义资源模式[META-INF / spring / * .xml]

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Camel Java DSL:无法解析bean定义资源模式[META-INF / spring / * .xml]相关的知识,希望对你有一定的参考价值。

我最近在合并了导致此堆栈跟踪的无关更改后遇到了Camel的情况:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:519)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [META-INF/spring/*.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/spring/] cannot be resolved to URL because it does not exist
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:229)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:612)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:513)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
    at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:222)
    at org.apache.camel.spring.Main.doStart(Main.java:154)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
    at org.apache.camel.main.MainSupport.run(MainSupport.java:170)
    at org.apache.camel.main.MainSupport.run(MainSupport.java:501)
    at org.apache.camel.spring.Main.main(Main.java:86)
    ... 6 more
Caused by: java.io.FileNotFoundException: class path resource [META-INF/spring/] cannot be resolved to URL because it does not exist
    at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:465)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:292)
    at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1291)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
    ... 21 more

代码合并没有搞乱maven pom文件中的任何内容,并且与Camel和Spring相对无关。我正在使用Java DSL来避免使用任何xml文件来配置Camel。如果我删除上述代码合并,这是有效的。我认为这是一个与我的pom配置相关的奇怪错误...有没有人使用Java DSL而不是xml配置有任何使用此错误的经验?有没有办法特别提到我使用DSL?如果我使用DSL,它甚至不应该寻找xml配置文件。

以下是我的POM文件的相关部分供参考:

<org.apache.camel.version>2.20.0</org.apache.camel.version>
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>1.4.1.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot-dependencies</artifactId>
        <version>${org.apache.camel.version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.4.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot-starter</artifactId>
        <version>${org.apache.camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${org.apache.camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-aws</artifactId>
        <version>${org.apache.camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>${org.apache.camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-javaconfig</artifactId>
        <version>${org.apache.camel.version}</version>
    </dependency>
答案

我设法从任何依赖项中删除提供的标记,并且它在启动spring应用程序时工作,但是,我无法使用mvn camel:run命令独立运行Camel。

<scope>import</scope>

这解决了目前解决障碍的一半问题。

以上是关于Camel Java DSL:无法解析bean定义资源模式[META-INF / spring / * .xml]的主要内容,如果未能解决你的问题,请参考以下文章

Apache Camel REST DSL 405方法不允许

Camel 和rabbitmq 集成处理

Apache Camel使用spring DSL比较字符串与引号,如何逃脱?

如何在apache camel DSL或camel Processor内部设置其他身份验证属性?

Camel Rest XML DSL分离文件夹结果Unmarshall Exception

Camel Rest DSL 检索 HTTP POST 多部分文件