1.进入官网:https://start.spring.io/ 看到如下界面
选择Maven创建方式
Group:一般为域名。例:net.soulless
Artifact:一般为项目名。例:soulless_springboot01
Dependencies:根据需求选择依赖
我们这里输入Web在下拉框中选择web
最后点击Generate Project生成项目导入Eclipse即可
在官方文档中可查询到示例Controller代码:
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.web.bind.annotation.*;
@RestController
@EnableAutoConfiguration
public class Example {
@RequestMapping("/")
String home() {
return "Hello World!"; } public static void main(String[] args) { SpringApplication.run(Example.class, args); } }
示例Controller创建后启动项目默认访问地址:localhost:8080