Handling of configuration files in Spring web applications

前端 未结 3 1844
南方客
南方客 2021-02-06 00:11

I have several times ran into the same problem, and I would like to have some input on what other people think about the issue: Suppose we have Spring application packaged as a

3条回答
  •  失恋的感觉
    2021-02-06 00:53

    For data sources; it is a common approach in tomcat context to create a JNDI resource entry and decouple your resource entries/configs from your application. If DB is changed, then you can reconfig your JNDI resource in your container (Tomcat,Jetty etc.) and restart. If you have a container farm, then it won't be a problem to restart your tomcat instances. you can deactivate them on load balancer and restart, reactivate. I think that there is a context file in Jetty also in which you can add JNDI resources. Moreover there is maven profiles for t he properties which depend on different contexts. you can select your profile with "-P" parameter of maven, and your project will be built with these configs, for example for the different target contexts like live and test.

提交回复
热议问题