当前位置: 首页> 教育> 幼教 > 成都小程序开发方案_宁波网站建设建站厂家_南宁百度seo排名优化_百度学术官网首页

成都小程序开发方案_宁波网站建设建站厂家_南宁百度seo排名优化_百度学术官网首页

时间:2025/7/11 15:15:33来源:https://blog.csdn.net/weixin_45571513/article/details/143608094 浏览次数:0次
成都小程序开发方案_宁波网站建设建站厂家_南宁百度seo排名优化_百度学术官网首页

1.枚举

public enum TestEnum {type_01("01", "zeroTest01ServiceImpl"),type_02("02", "zeroTest02ServiceImpl"),type_03("03", "zeroTest03ServiceImpl");private String type;private String pathClass;
}

2.接口

public interface ZeroTestService {/*** 校验** @param map*/void checkData(Map<String, String> map);/*** 当前实现对应类型** @return*/String getType();
}

3.实现类

@Service
public class ZeroTest02ServiceImpl implements ZeroTestService {@Overridepublic void checkData(Map<String, String> map) {}@Overridepublic String getType() {return null;}
}@Service
public class ZeroTest01ServiceImpl implements ZeroTestService {@Overridepublic void checkData(Map<String, String> map) {}@Overridepublic String getType() {return null;}
}

4.实现IOC容器

@Component
public class ZeroTestServiceFactory implements ApplicationContextAware {@Autowiredprivate ApplicationContext applicationContext;public Map<String, ZeroTestService> serviceMap = new HashMap<>();public ZeroTestService getZeroTestService(String type) {return serviceMap.get(type);}@Overridepublic void setApplicationContext(ApplicationContext context) throws BeansException {if (null == context) {context = applicationContext;}for (TestEnum testEnum : TestEnum.values()) {serviceMap.put(testEnum.getType(), (ZeroTestService) context.getBean(testEnum.getPathClass()));}}
}

关键字:成都小程序开发方案_宁波网站建设建站厂家_南宁百度seo排名优化_百度学术官网首页

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: