import java.lang.reflect.Method;
import org.springframework.util.ReflectionUtils;
ConfigurableApplicationContext run = SpringApplication.run(ShopApiApplication.class, args);
SpringContextUtil.setApplicationContext(run);
String[] beanDefinitionNames = run.getBeanDefinitionNames();// 所有bean的名称
for(String bn : beanDefinitionNames){
if (bn.endsWith("ServiceImpl")) {
try {
Object obj= SpringContextUtil.getBean(bn);
Method method = ReflectionUtils.findMethod(obj.getClass(), "getById", Serializable.class);
ReflectionUtils.invokeMethod(method, obj, 1);
} catch (Exception e) {
e.printStackTrace();
}
}