在枚举类声明一个内部类用于获取注入实例
@Component
private static class CustomInjector {
@Resource
private CustomService customService;
private static CustomService innerCustomService;
@PostConstruct
private void postConstruct() {
CustomInjector.innerCustomService= customService;
}
}
在枚举方法中调用注入实例方法
public static void testMethod() {
CustomInjector.innerCustomService.testMethod();
}