我正在学习在Spring Boot中使用Apache Camel。我正在做一个演示,我正在从FTP位置提取文件并将其拖放到其他位置。
当我直接在from()
方法中使用ftps uri时,路由有效。但是,当我尝试将ftps位置存储在application.properties文件中并从那里访问它时,出现了标记无效错误。
这有效:
@Override
public void configure() throws Exception {
fromFile();
}
public void fromFTP() {
from("ftps:username@localhost/pickup?password=xxxx&delete=true")
.to("file:E:/output");
}
这不是
:application.properties 文件
ftps.pickup.location=ftps:username@localhost/pickup?password=xxxx
骆驼路线
@Override
public void configure() throws Exception {
fromFile();
}
public void fromFTP() {
from("{{ftps.pickup.location}}&delete=true")
.to("file:E:/output");
}
这是我得到的错误:
C:\Users\pathaks\eclipse-workspace\camel-spring-demo>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building camel-spring-demo 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ camel-spring-demo --
-
[INFO] Deleting C:\Users\pathaks\eclipse-workspace\camel-spring-demo\target
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ camel-spri
ng-demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.996 s
[INFO] Finished at: 2018-11-17T17:56:48Z
[INFO] Final Memory: 22M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2
.7:resources (default-resources) on project camel-spring-demo: Mark invalid -> [
Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
pom.xml
<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>
<groupId>com.pathak</groupId>
<artifactId>camel-spring-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.17.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.21.3</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ftp</artifactId>
<version>2.21.3</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-csv</artifactId>
<version>2.21.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
有人可以指出我要去哪里了吗?预先感谢!
答案 0 :(得分:0)
这是Maven过滤的问题。 org.apache.maven.plugins:maven-resources-plugin:2.7:resources中存在一个错误。您得到的错误归结于正在创建的application.properties文件,而不是您的routebuilder中的更改。
springboot pom的父1.5.17.RELEASE引入了maven-resources-plugin 2.7。它具有以下功能,可以对资源文件进行过滤
<!-- Turn on filtering by default for application properties -->
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/application*.yml</include>
<include>**/application*.yaml</include>
<include>**/application*.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<excludes>
<exclude>**/application*.yml</exclude>
<exclude>**/application*.yaml</exclude>
<exclude>**/application*.properties</exclude>
</excludes>
</resource>
</resources>
使用Springboot parent的版本以及2.7以外的maven-resources-plugin的版本。
例如
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>