Handling multiple properties file in camel

65 views Asked by At

Our project used to have two kinds of properties in camel. One is for the default configuration and the other is a web service info. Once we package an entire project in a jar format. We placed the properties files in a separate folder (config). Which is present outside the jar file. Dynamically the web service properties are changed based on client requirements. It's better to keep it outside. So, to avoid every time building the jar file based on the web service property gets changed.

On reading the properties from the camel route, it was looking inside the jar directory of /config folder. We need to look outside of the /config folder.

enter image description here

The below code used to apply the properties

main.setPropertyPlaceholderLocations("file:config/scb-api-proxy.properties,config/scb-api-proxy-cred.properties,classpath:application.properties");

enter image description here

try {
            PropertiesComponent pc = new PropertiesComponent();
            String path = System.getProperty("user.dir") + "\\config123\\";
            System.out.println("***** PATH" + path);
            pc.setLocation("file:" + path +"scb-api-proxy.properties," + path +"scb-api-proxy-cred.properties,classpath:application.properties");
            
 
            context.setPropertiesComponent(pc);
            
            LOG.info("Loading the properties file " +  context.resolvePropertyPlaceholders(
                    "{{smartcore.api.proxy.credential:false}}"
                    .toString()));
            
            }catch(Exception err) {
                err.printStackTrace();
            }
    
0

There are 0 answers