一.File --> Project,选择Spring Starter Project
点击Next,这里有时候加载有点慢,可以等几秒
点击Next
这里直接点击Next项目就创建成功了,不需要选择额外的包。
实际项目如图所示。
为了方便测试在pom.xml加入spring-boot-starter-web依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
测试:
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "helloWorld";
}
}
点击运行,或者直接在对应的Application上点击运行也可。
这里没有报错就是对的,这里显示了SpringBoot运行的端口,在浏览器中打开即可,注意自己的控制台输出的端口号,替换在浏览器打开。如下图所示,我的为8080
http://localhost:8080/hello
如上图所示,我们的第一个SpringBoot项目就创建成功了。