我的第一个springboot程序
1.进入spring官网,spring.io
2.下载完之后,导入STS
3.导入成功之后
目录结构resources:
1.static:静态文件(图片、音频、js、css)
2.templates:模板文件(模板引擎freemarker、thymeleaf;springboot默认不支持jsp文件)
3.application.properties : 配置文件
扫描二维码关注公众号,回复:
3465710 查看本文章
运行SpringbootDemoApplication.java即可启动springboot项目
出现以下界面代表启动成功
4.测试
application.properties文件中可以指定tomcat端口,我这里是server.port=8080
创建一个HelloWorldController.java
package com.example.SpringbootDemo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloWorldController {
@RequestMapping("helloworld")
@ResponseBody
public String helloworld() {
return "helloworld;hello springboot";
}
}
启动springboot,输入localhost:8080\helloworld,启动成功
自此,我的第一个springboot程序运行成功!