我要做的是创建一个初始化日志代理的 Struts 基本操作。任何操作调用的所有服务都将使用此代理记录错误。然后由一个拦截器访问代理,然后执行实际的日志记录。一切都编译,构建。但是部署我在 Tomcat 7 上收到以下错误:
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 'com.blah.logging.LoggingProxy@58edf4c8' 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>
这可能很简单,但对 Spring EL 来说是新手。