0

我正在学习将 Apache Camel 与 Spring Boot 一起使用。我正在做一个演示,我正在从 FTP 位置获取文件并将其拖放到不同的位置。

当我直接在from()方法中使用 ftps uri 时,该路由有效。但是,当我尝试将 ftps 位置存储在 application.properties 文件中并从那里访问它时,我收到一个Mark Invalid错误。

这有效:

@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>

谁能指出我哪里出错了?提前致谢!

4

1 回答 1

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>

使用 2.7 以外的 maven-resources-plugin 版本的 springboot parent 版本。

例如

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>
于 2018-11-18T20:08:59.790 回答