expected at least 1 bean which qualifies as autowire candidate for this dependency

2018-4-13 10:29:55 org.apache.catalina.core.ApplicationContext log
严重: Error creating bean with name ‘materController’: Injection of autowired dependencies failed;Could not autowire field: No qualifying bean of type [com.cn.service.RelationService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.

原因:bean没有注入。


<context:component-scan base-package="com.imut.service" />
@Service("userService")
public class UserServiceImpl implements IUserService {
    private UserMapper userMapper;

    public UserMapper getUserMapper() {
        return userMapper;
    }
    @Autowired
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

解决:


<context:component-scan base-package="com.imut.serviceImpl" />

你可能感兴趣的:(BUG)