如何在Tomcat 8中创建新的共享文件夹并从中加载我的属性文件

时间:2021-07-24 13:27:51

I have a Spring MVC web application. I am now trying to externalize all the properties to keep it independent of the war file. I am trying to load some properties from my application.properties file. Also I want to load my database credentials also like this. Is there any way I can do this?

我有一个Spring MVC Web应用程序。我现在正在尝试外部化所有属性以使其独立于war文件。我正在尝试从我的application.properties文件中加载一些属性。另外我想加载我的数据库凭据也是这样的。有什么方法可以做到这一点吗?

I have in my root-contxt.xml file,

我有我的root-contxt.xml文件,

I tried the following: Adding a property file in the shared folder in tomcat 8 and using it in a Spring MVC web application

我尝试了以下操作:在tomcat 8的共享文件夹中添加属性文件,并在Spring MVC Web应用程序中使用它

But I have not found a solution yet.

但我还没有找到解决方案。

1 个解决方案

#1


0  

You can very well use PropertyPlaceholderConfigurer in Spring MVC to externalize properties file.

您可以在Spring MVC中使用PropertyPlaceholderConfigurer来外部化属性文件。

Please seethe post below which explains it in detail:

请在下面的帖子中详细解释:

PropertyPlaceholderConfigurer in Spring MVC

Spring MVC中的PropertyPlaceholderConfigurer

Please see below post as well which explains it with example:

请参阅下面的帖子,并通过示例解释:

Spring application context external properties?

Spring应用程序上下文外部属性

#1


0  

You can very well use PropertyPlaceholderConfigurer in Spring MVC to externalize properties file.

您可以在Spring MVC中使用PropertyPlaceholderConfigurer来外部化属性文件。

Please seethe post below which explains it in detail:

请在下面的帖子中详细解释:

PropertyPlaceholderConfigurer in Spring MVC

Spring MVC中的PropertyPlaceholderConfigurer

Please see below post as well which explains it with example:

请参阅下面的帖子,并通过示例解释:

Spring application context external properties?

Spring应用程序上下文外部属性