我要做的是创建一个初始化日志记录代理的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来说是新手。
答案 0 :(得分:0)
logger属性需要传递一个值:
<bean id="baseService" abstract="true"
<class="com.blah.service.impl.BaseServiceDatabaseImpl">
<property name="dataSource" ref="dataSource" />
<property name="logger" value="#{baseAction.logger}" />
</bean>