2016-08-02 96 views
0

我是新來的阿帕奇駱駝和春季啓動。我正在編寫一個應用程序,我需要將文件從文件夾傳輸到jms隊列。但在此之前,我正在嘗試將文件從一個文件夾轉移到另一個文件夾,這種情況沒有發生。在運行應用程序作爲彈簧引導應用程序時,輸入文件夾被創建。如果將該文件粘貼到此文件夾中,則目標文件夾不會形成,並且日誌語句也不會顯示。這是我添加的路線:阿帕奇駱駝目錄之間的副本文件

@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"); 
    } 
} 

回答

2

它應該工作,和它的工作對我來說,也許你還沒刷新工作區在你的IDE,如果這就是你如何跟蹤進度。

編輯

我現在看到的有什麼不對您的配置 - 你可能沒有在classpath彈簧引導起動網絡進行,因此你的主要方法不被阻塞並退出瞬間。

你應該從CamelApplication去除的主要方法,這條目添加到application.properties

spring.main.sources = com.example.CamelApplication 

或者,你可以改變你的主要方法運行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"); 
    } 
} 

或者,您可以添加這個給你的pom.xml強制一個嵌入式的Tomcat啓動並阻止你的主要方法:

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-web</artifactId> 
</dependency> 
+0

謝謝。我添加了spring-boot-starter-web的依賴關係,並且工作正常。 – Megha