Skip to content

快速开始

This content is not available in your language yet.

Feat Cloud 适合已经接受 Feat 技术路线,但又希望用更接近 Spring Boot 的注解式开发体验来构建应用的团队。

如果你还在评估 Feat,建议先从 Feat Core 快速开始 开始。

你将构建一个最小的注解式 Web 应用,访问 http://localhost:8080/hello 返回 hello Feat Cloud

前置要求:JDK 8+、Maven 3.0+、Java IDE

pom.xml 中加入:

pom.xml
<!--运行期依赖-->
<dependency>
<groupId>tech.smartboot.feat</groupId>
<artifactId>feat-cloud</artifactId>
<version>${feat.version}</version>
</dependency>
<!--编译期转码-->
<dependency>
<groupId>tech.smartboot.feat</groupId>
<artifactId>feat-cloud-starter</artifactId>
<version>${feat.version}</version>
<scope>provided</scope>
</dependency>

创建 Bootstrap.java

Bootstrap.java
import tech.smartboot.feat.cloud.FeatCloud;
import tech.smartboot.feat.cloud.annotation.Controller;
import tech.smartboot.feat.cloud.annotation.RequestMapping;
@Controller
public class Bootstrap {
@RequestMapping("/hello")
public String helloWorld() {
return "hello Feat Cloud";
}
public static void main(String[] args) {
FeatCloud.cloudServer().listen();
}
}

关键点:@Controller 声明控制器,@RequestMapping 声明路径,FeatCloud.cloudServer().listen() 启动服务。

运行 Bootstrap.main(),控制台出现以下内容说明路由注册成功:

Feat Router:
|-> /hello ==> Bootstrap@helloWorld
http://0.0.0.0:8080/

访问 http://localhost:8080/hello

Feat Cloud 浏览器访问效果图

完成第一个应用后,按以下顺序深入: