persistence.xml中的配置无法从spring cloud config获取值

时间:2016-10-27 14:03:28

标签: java spring cloud config persistence.xml

当我使用spring cloud配置时遇到有线问题。我在persistence.xml中配置了一个para,当我启动我的应用程序时,无法通过spring cloud config获取值。

Error creating bean with name 'dataSource' defined in URL     [jar:file:/home/jack/work/svn/business/health/za-hl-policy/20160921_13288_1/hl.policy.main/target/hl.policy.main.jar!/biz/persistence.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: The template variable 'tddl.appName' has no value
at    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:120)

这是我在beanRefContext.XML中的配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans            http://www.springframework.org/schema/beans/spring-beans.xsd           http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context.xsd"
default-autowire="byName">
<context:annotation-config />
<context:property-placeholder />
<context:component-scan base-package="com.zhongan.hl" />
<import resource="classpath*:biz/persistence.xml"/>
<import resource="classpath*:dal/sequence*.xml"/>
<import resource="classpath*:biz/spring-aop.xml"/>
<import resource="classpath*:biz/spring/*.xml"/>
</beans>

这是我在persistence.xml中的配置

<bean id="dataSource"     class="com.zhongan.zacat.client.jdbc.ZACatDataSource"
init-method="init" >
<property name="appName" value="${tddl.appName}" />
</bean>

0 个答案:

没有答案