2016-08-19 60 views
1

我使用org.apache.camel.main.Main類像這樣建立CAMEL應用:如何使用Java DSL訪問Apache Camel中的屬性文件?

public static void main(String... args) throws Exception { 

    Main main = new Main(); 

    main.enableHangupSupport(); 
    main.addRouteBuilder(new MainRoute()); 
    main.addRouteBuilder(ConfigurationRoute.getloginRoute()); 
    main.run(args); 
} 

如何將性能在代碼文件中(src /主/資源/ prop.properties)?

回答

2

您是否要爲屬性佔位符配置Camel屬性組件?

http://camel.apache.org/using-propertyplaceholder.html

我們很可能使這更容易對Main類配置,所以你可以把它配置到一個或多個屬性文件。

我已經登錄票使它更容易些:https://issues.apache.org/jira/browse/CAMEL-10255

你需要做的是

PropertiesComponent pc = new PropertiesComponent(); 
pc.setLocation("prop.properties"); 

main.bind("properties, pr); 

當你創建組件和配置。然後將其與ID properties綁定。

該位置是從類路徑自動加載的,因此您不需要src/main/resources作爲前綴。

相關問題