我想要做的是創建一個初始化日誌代理的Struts基本操作。任何操作調用的所有服務都將使用此代理來記錄錯誤。該代理然後由攔截器訪問,然後執行實際的日誌記錄。一切都在編譯,構建。但是部署我得到以下錯誤在Tomcat 7:在使用Spring EL時無法解析引用
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'journalVoucherService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean '#{baseAction.logger}' while setting bean property 'logger'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '[email protected]' is defined
這裏是我的applicationContext.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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<!-- Needed to run @PostConstruct initialization checking methods -->
<context:annotation-config />
<!-- Needed for @Transactional annotation -->
<tx:annotation-driven />
<!-- Journal Voucher Service -->
<bean id="journalVoucherService"
class="com.blah.service.impl.JournalVoucherServiceImpl"
parent="baseService">
</bean>
<!-- Base Service -->
<bean id="baseService" abstract="true"
class="com.blah.service.impl.BaseServiceDatabaseImpl">
<property name="dataSource" ref="dataSource" />
<property name="logger" ref="#{baseAction.logger}" />
</bean>
<!-- Loggging Proxy -->
<bean id="loggingProxy" class="com.blah.logging.LoggingProxy"/>
<!-- Struts 2 Actions -->
<bean id="baseAction"
class="com.blah.action.BaseAction">
<property name="logger" ref="loggingProxy" />
</bean>
</beans>
這可能是一些很簡單,但相信新的春天EL。
您是否嘗試過'$ {baseAction.logger}'?還不清楚你從哪裏/如何導入該值? – nickdos
感謝您的回覆。當我進行此更改時,我得到異常:org.springframework.beans.factory.BeanCreationException:在ServletContext資源[/WEB-INF/applicationContext.xml]中定義的名稱爲'journalVoucherService'的bean創建時出錯:無法解析在設置bean屬性'logger'時引用bean'$ {baseAction.logger}';嵌套的異常是org.springframework.beans.factory.NoSuchBeanDefinitionException:沒有名爲'$ {baseAction.logger}'的bean被定義爲 .....引起:org.springframework.beans.factory.NoSuchBeanDefinitionException:沒有名爲'$ {baseAction.logger}'被定義爲 – Robert
當你說我在哪裏我從我導入值我沒有做明確的導入。也許這是我的問題..我應該如何在我的應用程序文件中包含該導入? – Robert