tomcat - How to externalize application.properties to an external filesystem location in Spring Boot? -
tomcat - How to externalize application.properties to an external filesystem location in Spring Boot? -
@componentscan @enableautoconfiguration @propertysource(value = { "file:/users/documents/workspace/application.properties" }) public class application extends springbootservletinitializer{ public static void main(string[] args) { configurableapplicationcontext context = springapplication.run(application.class, args); }
in case gives while deploying:
org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [org.springframework.jdbc.core.jdbctemplate] found dependency:
not able find right way externalize application properties file
i tried autowiring environment variable correctly loaded need manually define beans
@bean public jdbctemplate datasource() { string driverclassname = env .getproperty("spring.datasource.driverclassname"); string dsurl = env.getproperty("spring.datasource.url"); string username = env.getproperty("spring.datasource.username"); string password = env.getproperty("spring.datasource.password"); //datasource datasource = new simpledriverdatasource(new driverclassname, dsurl, username, password); jdbctemplate jdbc = new jdbctemplate(datasource); homecoming jdbc; }
this deploys without throwing error not responding.
there no need define using @propertysource
annotation. should utilize spring.config.location
property set application.properties
location. property can set illustration in command line:
java -jar myapp.jar --spring.config.location=/users/documents/workspace/
spring tomcat deployment spring-boot
Comments
Post a Comment