0

I encounter wired issue when I use spring cloud config. And I config a para in persistence.xml, and can not get value with spring cloud config when I start my app.

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)

and this is my config in 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>

this is my config in persistence.xml

<bean id="dataSource"     class="com.zhongan.zacat.client.jdbc.ZACatDataSource"
init-method="init" >
<property name="appName" value="${tddl.appName}" />
</bean>
Clay
  • 4,700
  • 3
  • 33
  • 49
twocool
  • 11
  • 3
  • I'm not sure what you're asking here, in that there doesn't seem to be an actual question. Can you reformat the text so that it's easier to read? Right now it's a big block of text. – amadan Oct 27 '16 at 15:00
  • ok. I have a configuration in persistence.xml. value="${tddl.appName} , and I want to get the value of tddl.appName from spring cloud config when I run my application. But, I get nothing but null. The template variable 'tddl.appName' has no value – twocool Oct 28 '16 at 02:11

0 Answers0