- 1、创建SpringBoot项目-主启动类如下(NettyHandler是自定义注解,稍后会放出)
@SpringBootApplication
@ComponentScan(includeFilters = @ComponentScan.Filter(NettyHandler.class))
public class DemoMainApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(DemoMainApplication.class).web(WebApplicationType.NONE).run(args);
}
}
@Target({
ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Mapping
public @interface NettyHandler {
@AliasFor("path")
String[] value() default {
};
String name() default "";
RequestMethod[] method() default {
};
@AliasFor("value")
String[] path() default {
};
}
@Configuration
public class NettyServer implements ApplicationListener