我有一个简单的弹簧上下文文件如下:
<bean id="acl.provider" class="com.provider.ProviderType" factory-method="getInstance">
<constructor-arg index="0" value="${provider}"/>
</bean>
<bean id="acl.authentication" class="com.provider.AuthenticationFactory">
<constructor-arg index="0">
<value>#{ @acl.provider==T(com.provider.ProviderType).A
?'classpath:cfg/a.spax'
:null}</value>
</constructor-arg>
</bean>
当我初始化上面的上下文时会出现以下错误:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'acl' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1083)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.expression.BeanFactoryResolver.resolve(BeanFactoryResolver.java:44)
... 124 more
当我将acl.provider
bean名称更改为aclprovider
(删除.
字符)时,一切正常。
我的问题是:为什么.
字符在bean名称中使用并在SpEL
中使用?
答案 0 :(得分:0)
我在""
中找到了使用SpEL
的解决方案,如下所示:
<bean id="acl.provider" class="com.provider.ProviderType" factory-method="getInstance">
<constructor-arg index="0" value="${provider}"/>
</bean>
<bean id="acl.authentication" class="com.provider.AuthenticationFactory">
<constructor-arg index="0">
<value>#{ @"acl.provider"==T(com.provider.ProviderType).A
?'classpath:cfg/a.spax'
:null}</value>
</constructor-arg>
</bean>
我的问题解决了。