一、需要引用apache.camel 相关包。
build.gradle 定义如下:
buildscript {
ext {
springBootVersion = '2.1.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.apache.camel:camel-spring-boot-starter:2.23.0')
implementation('org.apache.camel:camel-core:2.23.0')
implementation('org.apache.camel:camel-ftp:2.23.0')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
二、编写一个Component,扩展RouteBuilder.class,重新实现configure方法。
设置数据源、目标,并且可以根据需要额外设置 过滤器Predicate和处理器Processor。
package com.example.ftpdemo;
import org.apache.camel.Loggin