Read common external property file in Java Webapp and java normal app

前端 未结 1 1484
闹比i
闹比i 2021-01-07 15:12

I know this question has answered many a time with most useful answer as below,

Where to place and how to read configuration resource files in servlet based applicat

1条回答
  •  感动是毒
    2021-01-07 15:28

    You can add a to tomcat/conf/server.xml (in this example, linux path):

    
    

    If you are using Windows:

    
    

    And then you can access it like any other resource within your webapp (e.g.: /assets/myappConfig.property).

    If you are using JDBC for example, you could store the connection properties in a Singleton and request it from there, and that class could take care of change checks on that file.

    0 讨论(0)
提交回复
热议问题