为什么spring的@autowired 注入为空,在jbpm4.4动态指定办理人时。

public class SetGM implements AssignmentHandler {

@Autowired
private UserService userService;

@Override
public void assign(Assignable assignable, OpenExecution execution)
        throws Exception {

    String userId = null;
    List<User> users = userService.findAll(); 
    for (User user : users) {
        for (Role role : user.getRoles()) {
            if (role.getName().equals("总经理")) {
                userId = user.getLoginName();
            }
        }
    }
    assignable.setAssignee(userId);
}

}

在配置中也扫描了。

单贴这一段代码 无法得知具体情况啊;比如你的UserService 是否重定义了 service名称;又或者 你的SetGM 类是否被扫描; SetGM 类没有注册成 spring的 bean的话,是不可以直接用 @Autowired 注入的