目的是像使用 springboot web starter 一样使用vertx, 目前可以使用的注解如下:
spring-web 注解中的
@RestController , @Controller , @RequestMapping , @RequestParam, @RequestBody
@PathVariable, @GetMapping. @PutMapping, @PostMapping, @DeleteMapping
@RequestHeader, @CookieValue
spring-validator 注解支持
新加的注解: @AsyncHandler 使用 vertx 异步模式 默认使用 vertx 阻塞模式,即 executeBlocking()
<dependency>
<groupId>com.github.zhengyuyzhao</groupId>
<artifactId>vertx-spring-boot-starter</artifactId>
<version>1.1.4</version>
</dependency>
vert:
port: 8000
work-pool-size: 100 // block mode 线程池大小
instance: 10 // verticle 部署实例数, 即evevtloop数量
@RequestMapping(value = "/test3/:id", method = RequestMethod.PUT)
public Map post(@RequestParam(value = "id") @NotNull int id,
@RequestParam(value = "qq", required = false, defaultValue = "333") int qq,
@RequestBody() Map map) {
}
@RequestMapping(value = "/test4", method = RequestMethod.GET)
public Map post4(RoutingContext context) {
}
@Component
public class Interceptor implements VertxHandlerInterceptor {
@Override
public boolean preHandle(RoutingContext context, Object handler) throws Exception {
HandlerMethod handlerMethod = (HandlerMethod) handler;
if(handlerMethod.getMethod().isAnnotationPresent(ResponseBody.class)){
context.response().end("not support responsebody");
return false;
}
return true;
}
}