java 获取接口所有的实现类

发布时间 2023-10-09 16:55:50作者: it-Curry
点击查看代码
@RequestMapping("test1")
    public String getCustImpl(){
        List<String> list = new ArrayList<String>();
        Map<String, CustImplService> beansOfType = applicationContext.getBeansOfType(CustImplService.class);
        for(Map.Entry<String, CustImplService> entry :beansOfType.entrySet()){
            CustImplService value = entry.getValue();
            System.out.println(entry.getKey());
            if(!"custImplService".equals(entry.getKey())){
                String str1 = value.getCustImpl();
                list.add(str1);
            }
        }
        return list.toString();
    }

java 枚举类的应用:
https://blog.csdn.net/m0_71777195/article/details/129613128