带有sringboot的Apache骆驼(春季DSL)

时间:2019-02-14 14:06:33

标签: java spring-boot apache-camel

我正在尝试使用Spring DSL通过Apache骆驼实现一个简单的post rest服务。但它没有映射任何路线,而且我也收到了此异常。

org.apache.camel.spring.boot.CamelSpringBootInitializationException: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.springframework.org/schema/beans", local:"beans"). Expected elements are <{http://camel.apache.org/schema/spring}aggregate>,<{http://camel.apache.org/schema/spring}aop>,<{http://camel.apache.org/schema/spring}apiKey>,<{http://camel.apache.org/schema/spring}asn1>,<{http://camel.apache.org/schema/spring}avro>,<{http://camel.apache.org/schema/spring}barcode>,<{http://camel.apache.org/schema/spring}base64>,<{http://camel.apache.org/schema/spring}basicAuth>,<{http://camel.apache.org/schema/spring}batch-config>,<{http://camel.apache.org/schema/spring}bean>,<{http://camel.apache.org/schema/spring}beanPostProcessor>,<{http://camel.apache.org/schema/spring}beanio>,<{http://camel.apache.org/schema/spring}bindy>,<{http://camel.apache.org/schema/spring}blacklistServiceFilter>,<{http://camel.apache.org/schema/spring}boon>,<{http://camel.apache.org/schema/spring}cachingServiceDiscovery>,<{http://camel.apache.org/schema/spring}camelContext>,<{http://camel.apache.org/schema/spring}castor>,<{http://camel.apache.org/schema/spring}choice>,<{http://camel.apache.org/schema/spring}circuitBreaker>,<{http://camel.apache.org/schema/spring}claimCheck>,<{http://camel.apache.org/schema/spring}combinedServiceDiscovery>,<{http://camel.apache.org/schema/spring}combinedServiceFilter>,<{http://camel.apache.org/schema/spring}constant>,<{http://camel.apache.org/schema/spring}consulServiceDiscovery>,<{http://camel.apache.org/schema/spring}consumerTemplate>,<{http://camel.apache.org/schema/spring}contextScan>,<{http://camel.apache.org/schema/spring}convertBodyTo>,<{http://camel.apache.org/schema/spring}crypto>,<{http://camel.apache.org/schema/spring}csv>,<{http://camel.apache.org/schema/spring}customDataFormat>,<{http://camel.apache.org/schema/spring}customLoadBalancer>,<{http://camel.apache.org/schema/spring}customServiceFilter>,<{http://camel.apache.org/schema/spring}dataFormats>,<{http://camel.apache.org/schema/spring}defaultLoadBalancer>,<{http://camel.apache.org/schema/spring}delay>,<{http://camel.apache.org/schema/spring}delete>,<{http://camel.apache.org/schema/spring}description>,<{http://camel.apache.org/schema/spring}dnsServiceDiscovery>,<{http://camel.apache.org/schema/spring}doCatch>,<{http://camel.apache.org/schema/spring}doFinally>,<{http://camel.apache.org/schema/spring}doTry>,<{http://camel.apache.org/schema/spring}dynamicRouter>,<{http://camel.apache.org/schema/spring}el>,<{http://camel.apache.org/schema/spring}endpoint>,<{http://camel.apache.org/schema/spring}enrich>,<{http://camel.apache.org/schema/spring}errorHandler>,<{http://camel.apache.org/schema/spring}etcdServiceDiscovery>,<{http://camel.apache.org/schema/spring}exchangeProperty>,<{http://camel.apache.org/schema/spring}export>,<{http://camel.apache.org/schema/spring}expression>,<{http://camel.apache.org/schema/spring}expressionDefinition>,<{http://camel.apache.org/schema/spring}failover>,<{http://camel.apache.org/schema/spring}fhirJson>,<{http://camel.apache.org/schema/spring}fhirXml>,<{http://camel.apache.org/schema/spring}filter>,<{http://camel.apache.org/schema/spring}flatpack>,<{http://camel.apache.org/schema/spring}fluentTemplate>,<{http://camel.apache.org/schema/spring}from>,<{http://camel.apache.org/schema/spring}get>,<{http://camel.apache.org/schema/spring}globalOption>,<{http://camel.apache.org/schema/spring}globalOptions>,<{http://camel.apache.org/schema/spring}groovy>,<{http://camel.apache.org/schema/spring}gzip>,<{http://camel.apache.org/schema/spring}head>,<{http://camel.apache.org/schema/spring}header>,<{http://camel.apache.org/schema/spring}healthyServiceFilter>,<{http://camel.apache.org/schema/spring}hessian>,<{http://camel.apache.org/schema/spring}hl7>,<{http://camel.apache.org/schema/spring}hystrix>,<{http://camel.apache.org/schema/spring}hystrixConfiguration>,<{http://camel.apache.org/schema/spring}ical>,<{http://camel.apache.org/schema/spring}idempotentConsumer>,<{http://camel.apache.org/schema/spring}inOnly>,<{http://camel.apache.org/schema/spring}inOut>,<{http://camel.apache.org/schema/spring}inputType>,<{http://camel.apache.org/schema/spring}intercept>,<{http://camel.apache.org/schema/spring}interceptFrom>,<{http://camel.apache.org/schema/spring}interceptSendToEndpoint>,<{http://camel.apache.org/schema/spring}jacksonxml>,<{http://camel.apache.org/schema/spring}javaScript>,<{http://camel.apache.org/schema/spring}jaxb>,<{http://camel.apache.org/schema/spring}jibx>,<{http://camel.apache.org/schema/spring}jmxAgent>,<{http://camel.apache.org/schema/spring}json>,<{http://camel.apache.org/schema/spring}jsonpath>,<{http://camel.apache.org/schema/spring}jxpath>,<{http://camel.apache.org/schema/spring}keyStoreParameters>,<{http://camel.apache.org/schema/spring}kubernetesServiceDiscovery>,<{http://camel.apache.org/schema/spring}language>,<{http://camel.apache.org/schema/spring}loadBalance>,<{http://camel.apache.org/schema/spring}loadBalancerConfiguration>,<{http://camel.apache.org/schema/spring}log>,<{http://camel.apache.org/schema/spring}loop>,<{http://camel.apache.org/schema/spring}lzf>,<{http://camel.apache.org/schema/spring}marshal>,<{http://camel.apache.org/schema/spring}method>,<{http://camel.apache.org/schema/spring}mime-multipart>,<{http://camel.apache.org/schema/spring}multiServiceDiscovery>,<{http://camel.apache.org/schema/spring}multiServiceFilter>,<{http://camel.apache.org/schema/spring}multicast>,<{http://camel.apache.org/schema/spring}mvel>,<{http://camel.apache.org/schema/spring}oauth2>,<{http://camel.apache.org/schema/spring}ognl>,<{http://camel.apache.org/schema/spring}onCompletion>,<{http://camel.apache.org/schema/spring}onException>,<{http://camel.apache.org/schema/spring}onFallback>,<{http://camel.apache.org/schema/spring}optimisticLockRetryPolicy>,<{http://camel.apache.org/schema/spring}options>,<{http://camel.apache.org/schema/spring}otherwise>,<{http://camel.apache.org/schema/spring}outputType>,<{http://camel.apache.org/schema/spring}packageScan>,<{http://camel.apache.org/schema/spring}param>,<{http://camel.apache.org/schema/spring}passThroughServiceFilter>,<{http://camel.apache.org/schema/spring}patch>,<{http://camel.apache.org/schema/spring}pgp>,<{http://camel.apache.org/schema/spring}php>,<{http://camel.apache.org/schema/spring}pipeline>,<{http://camel.apache.org/schema/spring}policy>,<{http://camel.apache.org/schema/spring}pollEnrich>,<{http://camel.apache.org/schema/spring}post>,<{http://camel.apache.org/schema/spring}process>,<{http://camel.apache.org/schema/spring}properties>,<{http://camel.apache.org/schema/spring}propertiesFunction>,<{http://camel.apache.org/schema/spring}propertiesLocation>,<{http://camel.apache.org/schema/spring}property>,<{http://camel.apache.org/schema/spring}propertyPlaceholder>,<{http://camel.apache.org/schema/spring}protobuf>,<{http://camel.apache.org/schema/spring}proxy>,<{http://camel.apache.org/schema/spring}put>,<{http://camel.apache.org/schema/spring}python>........

我没有在我的application-context.xml中弄错什么,因为我遵循了Apache骆驼的指导方针 这是我的application-context.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
    ">

    <bean id="activateOffer" class="com.globalcharge.bean.ActivateOffer"/>



    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <endpoint id="activateOfferUriGetRequestMethod" uri="bean:activateOffer?method=getRequest"/>
        <route>
            <from uri="activate" />
            <to ref="activateOfferUriGetRequestMethod" />
        </route>

    </camelContext>

</beans>

以下是我的主要课程

@SpringBootApplication
public class ApachecamelassignmentApplication {

    public static void main(String[] args) {

        SpringApplication.run(ApachecamelassignmentApplication.class, args);

        ConfigurableApplicationContext appContext = new ClassPathXmlApplicationContext(
                "camel-rest/application-context.xml");

    }

}

这是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>apachecamelproj</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>apachecamelproj</name>
    <description></description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>2.23.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-servlet-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jackson-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-swagger-java-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-servlet</artifactId>
            <version>2.23.1</version>
        </dependency>


    </dependencies>

</project>

0 个答案:

没有答案