java - Spring @PropertySource set path dynamically -
i developing core java application using spring core.and application work executable jar.
this application has configuration file load using @propertysource , path set "class-path:".
i install executable jar on different different machine. executable jar folder path different.
i need put projectconfig.properties outside jar file user can able set configuration per requirement. how can this?
how can set path dynamically?
import org.springframework.beans.factory.annotation.autowired; import org.springframework.context.annotation.propertysource; import org.springframework.core.env.environment; import org.springframework.stereotype.component; @component @propertysource("classpath:com/org/abc/xyz/properties/projectconfig.properties") public class projectconfig { @autowired private environment env; public string getproperty(string propname) { return env.getproperty(propname); } }
thank in advance!
i suggest use @configurationproperties
. spring boot
load application.properties
start folder or ./config folder. please read externalized configuration chapter spring boot development guide.
Comments
Post a Comment