springboot工程搭建
先搭建spring boot工程
点next 配置jdk版本,打包方式等
选择需要的组件会在创建工程时加入相关jar包
最后一步点击完成
等待加载jar包完成一个最简单的springboot项目就搭建好了
下面我们引入web组件
写一个简单的hello word
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class SpringbootDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootDemoApplication.class, args);
}
@RequestMapping("hello")
public String hello() {
return "Hello Spring Boot!";
}
}
下面我问启动工程
在浏览器输入localhost:8080/hello 就可以访问到了