properties - How can I create propirty file for sql queries in spring boot? -


i have sql queries in java code. want move property file. want create property file storing sql queries. have tried create:

sample.properties 

and write in file:

sql.getcalldetail = //sql query 

then in java class:

propertysource(value = "sample.properties") public class imeibuilderdefault implements imeibuilder {  @value("${sql.getcalldetail}")     private string getcalldetail; 

but project not build.

please go through below

 ** sql.properties **  queries.ex1="select * ex1" queries.ex2="select * ex2"  @propertysource(value="classpath:sql.properties") @configuration @configurationproperties public class sqlqueries {      private map<string,string> queries; //getters , setters }  **test class **  @component public class testsqlqueries {      @autowired     private sqlqueries queries;      @postconstruct     public void init(){          queries.getqueries().entryset().stream().foreach(entry->{             system.out.println(entry.getkey()+" "+entry.getvalue());         });     }  } 

please find demo project https://github.com/baratharivazhagan/spring-task-sample/tree/master/spring-sqlqueries-props


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -