Quick Start
引入依赖
<dependency>
<groupId>io.esastack</groupId>
<artifactId>restlight-spring</artifactId>
<version>${restlight.version}</version>
</dependency>
<dependency>
<groupId>io.esastack</groupId>
<artifactId>restlight-springmvc-provider</artifactId>
<version>${restlight.version}</version>
</dependency>
编写Controller并注入Spring
// Spring容器扫描并注入
@Controller
@RequestMapping("/hello")
public class HelloController {
@GetMapping(value = "/restlight")
public String restlight() {
return "Hello Restlight!";
}
}
使用Restlight4Spring启动Server
ApplicationContext context = ...
Restlight4Spring.forServer(context)
.daemon(false)
.server()
.start();
启动并访问: http://localhost:8080/hello 即可看到输出:
Hello Restlight!
Tip
同理其他Route, HandlerInterceptor,Filter等也可直接注入到Spring并作为参数启动Restlight4Spring配置启动。
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified March 10, 2022: introduce docsy as the website framework and add docs-v1.0.0 (#120) (79630ff)