1

現在、Struts2-spring プラグインを使用して Struts2 を使用して Web アプリケーションを作成しています。

ここに私のapplicationContext.xmlのスニペットがあります

<bean id="sessionFactory" scope="singleton"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="configLocation" value="classpath:hibernate.cfg.xml" />
    </bean>
    <!-- Springs Hibernate Transaction Manager -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <tx:annotation-driven />
    <!-- Create DAO Objects -->
    <bean id = "userDao" class = "org.hitplay.users.dao.UserDao" scope = "singleton">
        <property name ="sessionFactory" ref = "sessionFactory" />
    </bean>
    <bean id = "adminDao" class = "org.hitplay.admin.dao.AdminDao" scope = "singleton">
        <property name ="sessionFactory" ref = "sessionFactory" />
    </bean>
    <bean id="authenticateLoginService" class="org.hitplay.services.AuthenticateLoginService" scope="singleton">
        <property name="userDao" ref="userDao" />
        <property name="adminDao" ref="adminDao" />
    </bean>

    <bean id="accountAuthenticationManager" class="org.hitplay.authentication.manager.AccountAuthenticationManager" scope="singleton">
        <property name="authenticateLoginService" ref="authenticateLoginService" />
    </bean>

ここに私の AccountAuthenticationManager クラスがあります

@Transactional
public class AccountAuthenticationManager  implements AuthenticationManager {

 protected static Logger logger = Logger.getLogger("service");

 // Our custom DAO layer
 private AuthenticateLoginService authenticateLoginService;

 public AuthenticateLoginService getAuthenticateLoginService() {
    return authenticateLoginService;
}

public void setAuthenticateLoginService(
        AuthenticateLoginService authenticateLoginService) {
    this.authenticateLoginService = authenticateLoginService;
}

public Authentication authenticate(Authentication auth) throws AuthenticationException {

  System.out.println(authenticateLoginService);
 //Some more codes here
}

マッピングでわかるように、クラスauthenticateLoginService内にを注入しています。AccountAuthenticationManagerセッターとゲッターも提供しまし たが、メソッドauthenticateLoginServiceを実行するとわかるように、null が返されます。なぜこれが起こっているのかわかりません。AccountAuthenticationManager は Struts アクションではないことに注意してください
authenticate(Authentication auth)authenticationLoginService

現在、struts2-spring プラグインとスプリング セキュリティを使用しています。

4

1 に答える 1