我有一个 Spring MVC
网络应用程序。我现在正试图将所有属性外部化以使其独立于 war 文件。我正在尝试从我的 application.properties
文件加载一些属性。我也想像这样加载我的数据库凭据。我有什么办法可以做到这一点吗?
我在我的 root-contxt.xml
文件中,
我尝试了以下方法: Adding a property file in the shared folder in tomcat 8 and using it in a Spring MVC web application
但是我还没有找到解决办法。
最佳答案
您可以很好地使用 Spring MVC 中的 PropertyPlaceholderConfigurer 来外部化属性文件。
请参阅下面的帖子,其中详细解释了它:
PropertyPlaceholderConfigurer in Spring MVC
请参阅下面的帖子,其中用示例对其进行了解释:
关于java - 如何在 Tomcat 8 中创建一个新的共享文件夹并从中加载我的属性文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37241242/