api.IdmIdentityService‘ that could not be found.

在写flowable 工作流自定义用户组 和用户时,  重写获取用户,用户组接口时,根据网上其它人提供的代码:


import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.ManagementService;
import org.flowable.idm.api.Group;
import org.flowable.idm.api.IdmIdentityService;
import org.flowable.idm.api.User;
import org.flowable.ui.common.model.GroupRepresentation;
import org.flowable.ui.common.model.ResultListDataRepresentation;
import org.flowable.ui.common.model.UserRepresentation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
 
//www.1b23.com
@RestController
@RequestMapping("app")
public class UserAndGroupResourceController {
 
 @Autowired
 protected ManagementService managementService;
 @Autowired
protected IdmIdentityService idmIdentityService;
 
@RequestMapping(value = "/rest/editor-groups", method = RequestMethod.GET)
public ResultListDataRepresentation getGroups(@RequestParam(required = false, value = 
"filter") String filter) {
    if (StringUtils.isNotBlank(filter)) {
        filter = filter.trim();
        String sql = "select * from ACT_ID_GROUP where NAME_ like #{name}";
        filter = "%" + filter + "%";
        List<Group> groups = 
idmIdentityService.createNativeGroupQuery().sql(sql).parameter("name", filter).listPage(0, 10);
        List<GroupRepresentation> result = new ArrayList<>();
        for (Group group : groups) {
            result.add(new GroupRepresentation(group));
        }
        return new ResultListDataRepresentation(result);
    }
    return null;
 }
 
 @RequestMapping(value = "/rest/editor-users", method = RequestMethod.GET)
 public ResultListDataRepresentation getUsers(@RequestParam(value = "filter", required = false) 
String filter) {
    if (StringUtils.isNotBlank(filter)) {
        filter = filter.trim();
        String sql = "select * from ACT_ID_USER where ID_ like #{id} or LAST_ like #{name}";
        filter = "%"+filter+"%";
        List<User> matchingUsers = 
 idmIdentityService.createNativeUserQuery().sql(sql).
parameter("id",filter).parameter("name",filter).listPage(0, 10);List<UserRepresentation> 
userRepresentations = new ArrayList<>(matchingUsers.size());
        for (User user : matchingUsers) {
            userRepresentations.add(new UserRepresentation(user));
        }
        return new ResultListDataRepresentation(userRepresentations);
    }
    return null;
  }

出现报错:Consider defining a bean of type 'org.flowable.idm.api.IdmIdentityService' in your configuration.

提示我 IdmIdentityService 不能被找到,经过一番百度无果后,自己观察发现flowable的其它service  并不需要@autowired 注解:

去掉 IdmIdentityService 上的 @autowired注解后 ,就正常启动了 问题解决, 但是具体还不清楚,希望有大佬可以帮忙解释。

学习记录,不喜勿喷~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值