今天,日月 教大家一个快速搭建springBoot项目的方法,这里直接使用springboot官网的Quick start 创建方式。
进入springboot官网:http://spring.io/projects/spring-boot 拉倒最下面
Quick start
点击 Spring Initializr
创建后会自动下载到浏览器设置的下载目录中
我们解压后导入至IDE中查看
可以看到,已经帮助我们自动创建了启动类和pom依赖
我们创建一个controller
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SpringBootController {
@GetMapping("/hello")
public String hello(){
return "hello springBoot!!!";
}
}
启动springboot,在启动类SpringbootApplication.java的main方法中直接右键 Run As - java Application
通过日志,我们可以看到默认端口是8080
浏览器访问:http://localhost:8080/hello
至此,一个简单的springboot项目创建完成
如果该文章有帮助到您,就留言点个赞吧!您的支持与肯定是我持续更新最大的动力。