Meg*_*gan 0 java apache-camel spring-boot
我是apache camel和spring boot的新手.我正在编写一个应用程序,我需要将文件从文件夹传输到jms队列.但在此之前,我试图将文件从一个文件夹转移到另一个文件夹,这是没有发生的.在将应用程序作为spring boot应用程序运行时,将创建输入文件夹.如果将文件粘贴到此文件夹中,则不会形成目标文件夹,并且也不会显示日志语句.这是我添加路线的方式:
@SpringBootApplication
public class CamelApplication extends FatJarRouter {
public static void main(String ... args) {
SpringApplication.run(CamelApplication.class, args);
}
@Override
public void configure() throws Exception {
from("file:input?noop=true")
.log("Read from the input file")
.to("file:destination")
.log("Written to output file");
}
}
Run Code Online (Sandbox Code Playgroud)
它应该工作,它确实对我有用,也许你还没有在IDE中刷新你的工作区,如果这是你跟踪进度的方式.
编辑
我现在看到你的配置有什么问题了 - 你的类路径上可能没有spring-boot-starter-web所以你的主方法不会被阻止并立即退出.
您应该删除main方法CamelApplication并将此条目添加到application.properties:
spring.main.sources = com.example.CamelApplication
Run Code Online (Sandbox Code Playgroud)
或者,您可以更改要运行的主要方法CamelSpringBootApplicationController:
@SpringBootApplication
public class CamelApplication extends FatJarRouter {
public static void main(String... args) {
ApplicationContext applicationContext = SpringApplication.run(DemoApplication.class, args);
CamelSpringBootApplicationController applicationController =
applicationContext.getBean(CamelSpringBootApplicationController.class);
applicationController.run();
}
@Override
public void configure() throws Exception {
from("file:input?noop=true")
.log("Read from the input file")
.to("file:destination")
.log("Written to output file");
}
}
Run Code Online (Sandbox Code Playgroud)
或者,您可以将其添加到pom.xml以强制嵌入式Tomcat启动并阻止您的main方法:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3368 次 |
| 最近记录: |