是的,有可能
对于YAML属性
您必须使用
<bean id="yamlProperties" class="org.springframework.beans.factory.config.YamlPropertiesfactorybean">
<property name="resources" value="classpath:application.yml"/>
然后在src / main / resource / application.yaml中定义您的属性
bean:
name: foo
<bean name="${bean.name}"
class=”net.asifhossain.springmvcxml.web.FooBar”/>
这是我完整的XML配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/@R_403_875@s-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="yamlProperties" class="org.springframework.beans.factory.config.YamlPropertiesfactorybean">
<property name="resources" value="classpath:application.yaml"/>
</bean>
<context:property-placeholder properties-ref="yamlProperties"/>
<bean name="${bean.name}" class="net.asifhossain.springmvcxml.web.FooBar"/>
</beans>