当前位置: 首页 > 知识库问答 >
问题:

获取错误:org。springframework。豆。工厂未满足的费用例外

莘羽
2023-03-14

代码应该使用ApacheCamel路由将文件夹1中的内容复制到文件夹2,该路由使用Quartz触发。当我运行程序时,我会得到以下错误:“org。springframework。豆。工厂未满足的依赖项异常:创建名为“springCamelApplication”的bean时出错:未满足的依赖项通过字段“camelContext”和“由:org引起”表示。springframework。豆。工厂BeanCreationException:创建名为“camelContext”的bean时出错,该bean在类路径资源[org/apache/camel/spring/boot/CamelAutoConfiguration.class]中定义:合并bean定义的后处理失败;嵌套的异常是java。lang.IllegalStateException:未能从类加载器[jdk.internal.loader.ClassLoaders]中内省类[org.apache.camel.impl.DefaultCamelContext]$AppClassLoader@512ddf17].'

public class SpringCamelApplication {

    @Autowired
    CamelContext camelContext;

    public static void main(String[] args) {
        SpringApplication.run(SpringCamelApplication.class, args);
    }

    @Bean
    public FileRouteBuilder fileRouteBuilder() throws Exception {
        FileRouteBuilder routeBuilder = new FileRouteBuilder();
        camelContext.addRoutes(routeBuilder);
        return routeBuilder;

    }
}
public class FileRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("file:R://folder1?recursive=true&noop=true&scheduler=quartz2&scheduler.cron=0 0/1 * 1/1 * ? *").process(new Processor() {

            public void process(Exchange exchange) throws Exception {
                System.out.println("transferring " + exchange.getIn().getBody());

            }
        }).to("file:R://folder2");
    }
}
    <dependencies>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot</artifactId>
            <version>${camel.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
            <version>${camel.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${camel.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-quartz2</artifactId>
            <version>${camel.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.12</version>
        </dependency>

    </dependencies>

共有1个答案

司徒寒
2023-03-14

这可能是您的Java版本与Apache Camel版本不兼容的问题。你检查过你的Apache骆驼是否支持你的Java版本吗?

java8得到camel2的正式支持。x和可能或可能不适用于骆驼3。x、 而Java 11仅由Camel 3正式支持。十、

见:https://camel.apache.org/manual/latest/camel-3-migration-guide.html

 类似资料: