我正在使用 Spring IoC 容器为 Liferay Portal 5.2.3 和捆绑的 tomcat 6.0.18 开发一些 portlet。我需要将User_
Liferay 数据库中使用的表映射到具有 Hibernate 的实体,因此我需要使用两个不同的数据源将 Liferay db 与 portlet 使用的 db 分开。
我jdbc.properties
必须保存两个数据库的所有连接参数:portlet 使用的连接参数没有问题,但我在确定哪个数据库使用 liferay 保存其数据时遇到问题。
我的结论是我应该有这样的东西:
liferayConnection.url=jdbc:hsqldb:${liferay.home}/data/hsql/lportal
为了动态加载数据库url,根据portal-ext.properties中的Liferay属性。(或者,更好的是,从那里加载整个portal-ext.properties
并读取数据库属性)。
问题是占位符没有解决:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'liferayDataSource' defined in class path resource [WEB-INF/applicationContext.xml]: Could not resolve placeholder 'liferay.home'
为了避免这个问题,我尝试portal-ext.properties
使用 Spring bean 显式加载:
<bean id="liferayPropertiesConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="../../portal-ext.properties"/>
但没有运气: liferay.home 没有解决,但没有其他错误。
如何解决 Liferay 定义的占位符?谢谢