使用intellj IDEA搭建SpringBoot项目
-
springBoot作为当下很流行的框架,因其高性能和简化配置收到广大开发人员的青睐。
-
那么如果搭建一个SpringBoot项目呢。今天我来给大家演示下最简单的搭建教程。
一、创建一个project
二、选择Spring Initializr,然后直接next
三、修改自己的groupid和artifactId,点击next
四、选择需要的属性,这里我简单的选择web,你可以根据自己的需要加上mysql、MongoDB、myBatis等,另外右上角还可以设置boot的版本
五、填写项目名称然后就完成了。
六、打开项目后架构如图,直接删除该3个文件
七、默认的启动类就是DemoApplication
八、这里写一个contoller测试一下
代码如下:
-
package com.example.demo;
-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-
import org.springframework.web.bind.annotation.RequestMapping;
-
import org.springframework.web.bind.annotation.RestController;
-
/**
-
* @Created by liuchujian On 2018/7/5
-
*/
-
@RestController
-
@EnableAutoConfiguration
-
public class IndexController {
-
@RequestMapping("/index")
-
public String sayHello() {
-
return "hello! this is my first springboot code!";
-
}
-
}
九、运行main方法启动boot,在浏览器输入 http://localhost:8080/index访问如图
大功告成!一个简单的springBoot项目就此搭建完成!喜欢可以关注一波哦~