Accessing values from Alfresco's alfresco-global.properties file

陌路散爱 提交于 2019-12-19 07:32:17

问题


Lets say I create a custom property called "test123" inside of the alfresco-global.properties file. Is there a custom object or some other way which I can use to access its value inside of a Java bean in Alfresco?


回答1:


The Spring bean is called "global-properties" and it's a java.util.Properties type

So you can inject it like that:

<property name="properties">
  <ref bean="global-properties"/>
</property

and add a properties property of type java.util.Properties to your bean




回答2:


All properties from the alfresco-global.properties are available as placeholders in the Spring bean definition. You can simply use:

<property name="myCustomOption" value="${my.custom.option}"/>

in your bean definition and in alfresco-global.properties:

my.custom.option=Some string value

Injecting the whole global-properties bean (as proposed above) also works but violates the principle of least knowledge.




回答3:


You may also use PropertyPlaceholderConfigurer, see last snippet within this post.



来源:https://stackoverflow.com/questions/10452800/accessing-values-from-alfrescos-alfresco-global-properties-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!