1

私がやろうとしているのは、ロギング プロキシを初期化する 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 は初めてです。

4

1 に答える 1

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>
于 2012-11-26T18:11:58.047 に答える