为什么在执行时总是得到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>
在dispatcher上下文中,我已经定义要扫描包:
<context:component-scan base-package="com.springweb"/>