Reputation: 87
I build camel application using org.apache.camel.main.Main class like this:
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);
}
how to include properties file (src/main/resources/prop.properties) in the code?
Upvotes: 1
Views: 1232
Reputation: 55760
Do you mean to configure the Camel properties component for properties placeholders?
http://camel.apache.org/using-propertyplaceholder.html
We could probably make this easier to configure on the Main
class so you can configure it to one or more properties files.
I have logged a ticket to make this easier: https://issues.apache.org/jira/browse/CAMEL-10255
What you need to do is to
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("prop.properties");
main.bind("properties, pr);
Where you create the component and configure it. And then bind it with the id properties
.
The location is automatic loaded from the classpath, so you do not need src/main/resources
as prefix.
Upvotes: 2