简体   繁体   English

使用Spring框架从JBoss服务器读取外部属性文件

[英]Read external property files from JBoss server using Spring framework

I'm currently working on a Spring project where in I need to read some external property files from JBoss server. 我目前正在开发一个Spring项目,在其中我需要从JBoss服务器读取一些外部属性文件。 I'm able to read the external property files from JBoss server with the help of this article. 我能够的帮助下阅读从JBoss服务器的外部属性文件, 文章。 I'm keen to know whether we can achieve this using the spring PropertySourcesPlaceholderConfigurer or Environment classes. 我很想知道我们是否可以使用Spring PropertySourcesPlaceholderConfigurerEnvironment类来实现这一目标。

The answer is pretty straight forward. 答案很简单。 When ever we add the property files to the JBoss Server module folder($JBOSS_HOME\\modules) and add the dependency in the jboss-deployment-structure.xml. 每当我们将属性文件添加到JBoss Server模块文件夹($ JBOSS_HOME \\ modules),并将依赖项添加到jboss-deployment-structure.xml中。 All the added external property files will exist in the classpath. 所有添加的外部属性文件都将存在于类路径中。

We can simply use the @PropertySource and Environment class provided by the spring framework to read the property values. 我们可以简单地使用spring框架提供的@PropertySource和Environment类来读取属性值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM