为什么我在执行时总是得到 userDetailDao 异常 null :
package com.springweb.service;
import com.springweb.dao.UserDetailDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.dao.DataAccessException;
import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UserDetailsService;
import org.springframework.security.userdetails.UsernameNotFoundException;
public class UserService implements UserDetailsService
{
@Autowired
UserDetailDao userDetailDao;
public UserDetails loadUserByUsername(String string) throws UsernameNotFoundException, DataAccessException {
return userDetailDao.queryForUser(string);
}
}
在我的春季安全配置中:
<security:authentication-provider user-service-ref="userService">
<security:password-encoder hash="md5" />
</security:authentication-provider>
<bean name="userService" class="com.springweb.service.UserService">
</bean>
在我的调度程序上下文中,我已经定义扫描包:
<context:component-scan base-package="com.springweb"/>