1.使用spring initializer快速创建spring boot 项目
ide都支持使用spring的项目创建向导快速创建一个spring boot项目,需要选择需要的模块。向导会联网创建springboot项目。
没用的src删掉。
pom文件中导入的test帮助我们单元测试。
@ResponseBody//这个类的所有方法返回值直接写给浏览器 @Controller @RestController 这个注解直接涵盖上面两个注解
默认生成的spring boot项目主程序已经生成,只需要编写业务逻辑。
resources文件夹目录结构
static保存所有的静态资源包括jsp,image,css
templates保存所有的模板页面,spring boot默认jar包使用嵌入式tomcat,不支持jsp页面的。
可以使用模板引擎。free marker thymeleaf
application properties springboot 的应用配置文件。修改server.port=8081访问时就要访问8081