由于骆驼上下文引起的错误,我无法 运行 我的程序,我应该怎么做才能解决这个问题?

I could not run my program due to error caused by the camel context, what should I do to resolve this?

所以我在这里要做的是通过 camel apache 创建一个 zoom 会议。每当我 运行 程序和导致错误的行是当我启动骆驼上下文 c.start() 时,我总是收到错误 这是我 运行:

的代码
    package com.example.demo;

    import com.google.gson.Gson;
    import com.google.gson.JsonObject;
    import org.apache.camel.*;
    import org.apache.camel.builder.RouteBuilder;
    import org.apache.camel.impl.DefaultCamelContext;
    import org.apache.camel.model.dataformat.JsonLibrary;

    import static org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.json;

public class Test {
    private String token = "sample token";
    public static void main(String[] args) throws Exception {
        CamelContext c = new DefaultCamelContext();
        settings set = new settings(true, true, false,
                false, true,"voip","cloud");
        recurrence rec = new recurrence(1,1);
        c.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:start")
                        .process(exchange -> exchange.getIn().setBody(new ZoomSetting(
                                "Testing zoom api",
                                2,
                                "2022-05-09T14: 00: 00",
                                45,
                                "America/New_York",
                                "testing",
                                rec,
                                set
                        )))
                        .marshal().json(JsonLibrary.Gson)
                        .setHeader(Exchange.HTTP_METHOD, constant("POST"))
                        .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
                        .setHeader("Authorization", simple("Bearer"+ token))
                        .to("https://api.zoom.us/v2/users/me/meetings")
                        .process(exchange -> log.info("The response code is: {}", exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)));
            }
        });
        c.start();

    }
}

我试图将依赖项包含在 pom.xml 文件中,但这并没有真正帮助。这是我在 pom.xml:

中包含的依赖项
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.camel.springboot</groupId>
        <artifactId>camel-spring-boot-starter</artifactId>
        <version>3.16.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-http-starter -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-http-starter</artifactId>
        <version>3.0.0-RC3</version>
    </dependency>


    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.auth0</groupId>
        <artifactId>java-jwt</artifactId>
        <version>3.19.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-rest</artifactId>
        <version>3.16.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-gson</artifactId>
        <version>3.16.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-direct</artifactId>
        <version>3.16.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-http</artifactId>
        <version>3.16.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>3.16.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-context</artifactId>
        <version>2.25.4</version>
    </dependency>




</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

我不断收到的错误是:

线程“main”中的异常java.lang.AbstractMethodError: 接收器class org.apache.camel.management.JmxManagementLifecycleStrategy 未定义或继承已解析方法抽象onRouteContextCreate(Lorg/apache/camel/Route;)V 的实现接口 org.apache.camel.spi.LifecycleStrategy。 在 org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:213) 在 org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74) 在 org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49) 在 org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:887) 在 org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:775) 在 org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2937) 在 org.apache.camel.support.service.BaseService.init(BaseService.java:83) 在 org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2620) 在 org.apache.camel.support.service.BaseService.start(BaseService.java:111) 在 org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2639) 在 org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:255) 在 com.example.demo.Test.main(Test.java:42)

如果你想 运行 camel 使用 main 方法,你应该使用 camel-main,它适用于 运行ning 独立的 camel 应用程序。您正在尝试做的是 运行ning camel 作为独立应用程序但使用 camel-spring-boot 依赖项。

您可以使用 maven archetype camel-archetype-main 生成新的独立 camel 应用程序项目,并将其用作如何设置项目的参考。

mvn archetype:generate -DarchetypeGroupId="org.apache.camel.archetypes" -DarchetypeArtifactId="camel-archetype-main" -DarchetypeVersion="3.14.3"

如果你想使用spring-frameworkspring-boot到运行骆驼那么你可以使用 camel-archetype-spring-boot 原型来生成示例 camel spring-boot 项目。我建议在使用 camel 之前熟悉 Spring-framework 和 Spring-boot 的基础知识以避免不必要的混淆。

mvn archetype:generate -DarchetypeGroupId="org.apache.camel.archetypes" -DarchetypeArtifactId="camel-archetype-spring-boot" -DarchetypeVersion="3.14.3"