Java CamelContext CamelContext=SpringCamelContext.SpringCamelContext(appContext,false);驼峰版本2.17.3中已弃用

Java CamelContext CamelContext=SpringCamelContext.SpringCamelContext(appContext,false);驼峰版本2.17.3中已弃用,java,apache-camel,apache-camel-cdi,Java,Apache Camel,Apache Camel Cdi,我使用的是Spring+apachecamel示例。在前面的这个示例中,我使用的是驼峰核心版本2.15.1。现在,我刚刚将依赖项更新为2.17.3,当我更新依赖项时,我看到下面的方法被弃用: CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false); 替换代码是什么 请参阅我的以下代码: cameltimerfeedingactivemqe示例 public class CamelT

我使用的是
Spring+apachecamel
示例。在前面的这个示例中,我使用的是
驼峰核心版本2.15.1
。现在,我刚刚将依赖项更新为
2.17.3
,当我更新依赖项时,我看到下面的方法被弃用:

CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false);
替换代码是什么

请参阅我的以下代码: cameltimerfeedingactivemqe示例

public class CamelTimerFeedingActiveMqExample {
    public static final void main(String[] args) throws Exception {
        ApplicationContext appContext = new ClassPathXmlApplicationContext("timerFeedActiveMqApplicationContext.xml");
        CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false);
        try {
            camelContext.start();
            Thread.sleep(5000);
        } finally {
            camelContext.stop();
        }
    }
}
applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<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="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="activemq:queue:numbers" />
            <to uri="log:com.javarticles?level=INFO&amp;groupInterval=10000" />
        </route>
    </camelContext> 
</beans>
<?xml version="1.0" encoding="UTF-8"?>

<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="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route id="timerPingToInQueue">
            <from uri="timer:ping?period=1s" />
            <transform>
                <simple>Ping at ${date:now:yyyy-MM-dd HH:mm:ss}</simple>
            </transform>
            <to uri="activemq:queue:ping_queue" />
        </route>
        <route id="InQueueToConsole">
            <from uri="activemq:queue:ping_queue" />
            <to uri="stream:out" />
        </route>
    </camelContext>
</beans>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    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
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

    <context:property-placeholder location="classpath:database.properties"/>

    <bean id="orderProcessor" class="com.javarticles.camel.components.OrderProcessor"/>

    <jdbc:initialize-database data-source="dataSource" enabled="true">
        <jdbc:script location="classpath:db-schema.sql" />
        <jdbc:script location="classpath:db-test-data.sql" />
    </jdbc:initialize-database>


    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${mysql.driver.class.name}" />
        <property name="url" value="${mysql.url}" />
        <property name="username" value="${mysql.username}" />
        <property name="password" value="${mysql.username}" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="timer://queryTimer?period=2s" />
            <setBody>
                <constant>
                    SELECT * FROM ORDERS WHERE STATUS='NEW' ORDER BY NAME
                </constant>
            </setBody>
            <to uri="jdbc:dataSource" />
            <split>
                <simple>${body}</simple>
                <to uri="bean:orderProcessor" />
            </split>
        </route>
    </camelContext>
</beans>
<properties>
        <!-- General Properties -->
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Apache Camel -->
        <apache.camel.version>2.17.3</apache.camel.version>

        <!-- Spring Framework -->
        <spring.version>4.3.1.RELEASE</spring.version>

        <!-- MYSQL -->
        <mysql.version>5.1.39</mysql.version>

        <!-- Logging Framework -->
        <logback.version>1.1.7</logback.version>
        <jcl-over-slf4j.version>1.7.21</jcl-over-slf4j.version>

        <!-- Junit Framework -->
        <junit.version>4.12</junit.version>
    </properties>


    <dependencies>
        <!-- Spring Context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Spring JDBC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- Camel core -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

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

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

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

        <!-- camel JDBC -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jdbc</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

        <!-- MYSQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

timerFeedActiveMqApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<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="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="activemq:queue:numbers" />
            <to uri="log:com.javarticles?level=INFO&amp;groupInterval=10000" />
        </route>
    </camelContext> 
</beans>
<?xml version="1.0" encoding="UTF-8"?>

<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="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route id="timerPingToInQueue">
            <from uri="timer:ping?period=1s" />
            <transform>
                <simple>Ping at ${date:now:yyyy-MM-dd HH:mm:ss}</simple>
            </transform>
            <to uri="activemq:queue:ping_queue" />
        </route>
        <route id="InQueueToConsole">
            <from uri="activemq:queue:ping_queue" />
            <to uri="stream:out" />
        </route>
    </camelContext>
</beans>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    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
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

    <context:property-placeholder location="classpath:database.properties"/>

    <bean id="orderProcessor" class="com.javarticles.camel.components.OrderProcessor"/>

    <jdbc:initialize-database data-source="dataSource" enabled="true">
        <jdbc:script location="classpath:db-schema.sql" />
        <jdbc:script location="classpath:db-test-data.sql" />
    </jdbc:initialize-database>


    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${mysql.driver.class.name}" />
        <property name="url" value="${mysql.url}" />
        <property name="username" value="${mysql.username}" />
        <property name="password" value="${mysql.username}" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="timer://queryTimer?period=2s" />
            <setBody>
                <constant>
                    SELECT * FROM ORDERS WHERE STATUS='NEW' ORDER BY NAME
                </constant>
            </setBody>
            <to uri="jdbc:dataSource" />
            <split>
                <simple>${body}</simple>
                <to uri="bean:orderProcessor" />
            </split>
        </route>
    </camelContext>
</beans>
<properties>
        <!-- General Properties -->
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Apache Camel -->
        <apache.camel.version>2.17.3</apache.camel.version>

        <!-- Spring Framework -->
        <spring.version>4.3.1.RELEASE</spring.version>

        <!-- MYSQL -->
        <mysql.version>5.1.39</mysql.version>

        <!-- Logging Framework -->
        <logback.version>1.1.7</logback.version>
        <jcl-over-slf4j.version>1.7.21</jcl-over-slf4j.version>

        <!-- Junit Framework -->
        <junit.version>4.12</junit.version>
    </properties>


    <dependencies>
        <!-- Spring Context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Spring JDBC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- Camel core -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

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

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

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

        <!-- camel JDBC -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jdbc</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

        <!-- MYSQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

在${date:now:yyyy-MM-dd HH:MM:ss}进行Ping
timerSelectQueryApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<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="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="activemq:queue:numbers" />
            <to uri="log:com.javarticles?level=INFO&amp;groupInterval=10000" />
        </route>
    </camelContext> 
</beans>
<?xml version="1.0" encoding="UTF-8"?>

<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="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route id="timerPingToInQueue">
            <from uri="timer:ping?period=1s" />
            <transform>
                <simple>Ping at ${date:now:yyyy-MM-dd HH:mm:ss}</simple>
            </transform>
            <to uri="activemq:queue:ping_queue" />
        </route>
        <route id="InQueueToConsole">
            <from uri="activemq:queue:ping_queue" />
            <to uri="stream:out" />
        </route>
    </camelContext>
</beans>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    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
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

    <context:property-placeholder location="classpath:database.properties"/>

    <bean id="orderProcessor" class="com.javarticles.camel.components.OrderProcessor"/>

    <jdbc:initialize-database data-source="dataSource" enabled="true">
        <jdbc:script location="classpath:db-schema.sql" />
        <jdbc:script location="classpath:db-test-data.sql" />
    </jdbc:initialize-database>


    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${mysql.driver.class.name}" />
        <property name="url" value="${mysql.url}" />
        <property name="username" value="${mysql.username}" />
        <property name="password" value="${mysql.username}" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="timer://queryTimer?period=2s" />
            <setBody>
                <constant>
                    SELECT * FROM ORDERS WHERE STATUS='NEW' ORDER BY NAME
                </constant>
            </setBody>
            <to uri="jdbc:dataSource" />
            <split>
                <simple>${body}</simple>
                <to uri="bean:orderProcessor" />
            </split>
        </route>
    </camelContext>
</beans>
<properties>
        <!-- General Properties -->
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Apache Camel -->
        <apache.camel.version>2.17.3</apache.camel.version>

        <!-- Spring Framework -->
        <spring.version>4.3.1.RELEASE</spring.version>

        <!-- MYSQL -->
        <mysql.version>5.1.39</mysql.version>

        <!-- Logging Framework -->
        <logback.version>1.1.7</logback.version>
        <jcl-over-slf4j.version>1.7.21</jcl-over-slf4j.version>

        <!-- Junit Framework -->
        <junit.version>4.12</junit.version>
    </properties>


    <dependencies>
        <!-- Spring Context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Spring JDBC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- Camel core -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

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

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

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

        <!-- camel JDBC -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jdbc</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

        <!-- MYSQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

按名称从状态为“新建”的订单中选择*
${body}
pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<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="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="activemq:queue:numbers" />
            <to uri="log:com.javarticles?level=INFO&amp;groupInterval=10000" />
        </route>
    </camelContext> 
</beans>
<?xml version="1.0" encoding="UTF-8"?>

<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="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route id="timerPingToInQueue">
            <from uri="timer:ping?period=1s" />
            <transform>
                <simple>Ping at ${date:now:yyyy-MM-dd HH:mm:ss}</simple>
            </transform>
            <to uri="activemq:queue:ping_queue" />
        </route>
        <route id="InQueueToConsole">
            <from uri="activemq:queue:ping_queue" />
            <to uri="stream:out" />
        </route>
    </camelContext>
</beans>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    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
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

    <context:property-placeholder location="classpath:database.properties"/>

    <bean id="orderProcessor" class="com.javarticles.camel.components.OrderProcessor"/>

    <jdbc:initialize-database data-source="dataSource" enabled="true">
        <jdbc:script location="classpath:db-schema.sql" />
        <jdbc:script location="classpath:db-test-data.sql" />
    </jdbc:initialize-database>


    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${mysql.driver.class.name}" />
        <property name="url" value="${mysql.url}" />
        <property name="username" value="${mysql.username}" />
        <property name="password" value="${mysql.username}" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="timer://queryTimer?period=2s" />
            <setBody>
                <constant>
                    SELECT * FROM ORDERS WHERE STATUS='NEW' ORDER BY NAME
                </constant>
            </setBody>
            <to uri="jdbc:dataSource" />
            <split>
                <simple>${body}</simple>
                <to uri="bean:orderProcessor" />
            </split>
        </route>
    </camelContext>
</beans>
<properties>
        <!-- General Properties -->
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Apache Camel -->
        <apache.camel.version>2.17.3</apache.camel.version>

        <!-- Spring Framework -->
        <spring.version>4.3.1.RELEASE</spring.version>

        <!-- MYSQL -->
        <mysql.version>5.1.39</mysql.version>

        <!-- Logging Framework -->
        <logback.version>1.1.7</logback.version>
        <jcl-over-slf4j.version>1.7.21</jcl-over-slf4j.version>

        <!-- Junit Framework -->
        <junit.version>4.12</junit.version>
    </properties>


    <dependencies>
        <!-- Spring Context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Spring JDBC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- Camel core -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

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

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

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

        <!-- camel JDBC -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jdbc</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

        <!-- MYSQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

1.8
UTF-8

您只需使用以下命令即可。完成了

public class CamelTimerSqlQueryExample {
    public static final void main(String[] args) throws Exception {
        ApplicationContext appContext = new ClassPathXmlApplicationContext("timerSelectQueryApplicationContext.xml");
        CamelContext camelContext = new SpringCamelContext(appContext) ;
        try {
            camelContext.start();
            Thread.sleep(5000);
        } finally {
            camelContext.stop();
        }
    }
}

我找这个已经有一段时间了!非常感谢。