spring boot project xml bean in jar can not refer application.properties

42 Views Asked by At

I have a springboot project, and import jar.

1.there is a test.xml bean(implements BeanDefinitionRegistryPostProcessor) in the jar and the bean have a property use placeholder like this:

<property name="name" value="${value}"/>
2.There is
@ImportResource({"classpath*:test.xml"}) and @SpringBootApplication on Application.java

3.there is a placeholder defined in application.properties, like this:

value=1.0.0

however the project cannot run, have the error

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'value' in value "${value}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178)
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:166)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:232)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:296)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:217)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:147)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:85)
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:225)

can anyone help. thanks

0

There are 0 best solutions below