mule/java - reading a property file which is inside of jar dependency from java class -
here requirement is, have created 1 mule application has java class. of values don't want keep hard-coded trying externalize it. kept values in mule-app.properties file , used fileinputstream below.
string propfilename = "src/main/app/mule-app.properties" properties property = new properties(); property.load(new fileinputstream(propfilename));
but code needs deployed on cloudhub; there failing saying file not found. tried give path of file name
string propfilename = "target/classes/mule-app.properties"
for both cases running fine locally gives same results on cloudhub "file not found".
what solution?
another thing have common code in keeping properties related different environment. packaging of common code in form of jar. so, can keep properties using in above code , read jar itself.
if yes, how?
if want deploy in cloudhub , externalize properties file better use cloudhub properties tab externalize values.
ref:- https://docs.mulesoft.com/runtime-manager/deploying-to-cloudhub#properties-tab
and in java class can pick properties value using :- system.getproperty("yourpropertykey")
simple :)
regarding keeping properties file in common jar app, need use <context:property-placeholder/>
pick properties file classpath of common jar application , can use in host application mule flow
Comments
Post a Comment