protected <T> Class<T> asService(Class<T> serviceInterface, String path) throws Exception { net.bytebuddy.dynamic.DynamicType.Builder<T> subclass = new ByteBuddy().subclass(serviceInterface); if(!serviceInterface.isAnnotationPresent(RestController.class) && !serviceInterface.isAnnotationPresent(Controller.class)) { subclass = subclass.annotateType(AnnotationDescription.Builder.ofType(RestController.class).build()); } if(path != null) { subclass = subclass.annotateType(AnnotationDescription.Builder.ofType(org.springframework.web.bind.annotation.RequestMapping.class).defineArray("path", new String[]{path}).build()); } Loaded<T> load = subclass.make().load(classLoader, ClassLoadingStrategy.Default.INJECTION); return (Class<T>) load.getLoaded(); }