Spring Boot开发web项目(Gradle版)

1、登录https://start.spring.io/官网,快速生成Spring Boot 的基本框架。                                                                                           Spring Boot开发web项目(Gradle版)

2、点击Generate Project 生成Spring Boot工程的压缩包。

3、将2中生成的压缩包解压后,导入到IDE(开发环境)中。(注:本文用IntelliJ IDEA)

Spring Boot开发web项目(Gradle版)

4、此时通过注解方式,创建controller

Spring Boot开发web项目(Gradle版)

5、在application.properties中配置页面配置、log配置和其它包括数据库的配置等等。(由于在Spring Boot中对thymeleaf模板支持较好,因此用它作为前台页面的展示,相对简单。

               Spring Boot开发web项目(Gradle版)

6、在工程的resources下的templates目录下创建index.html,以thymeleaf模板的模式创建页面。

             Spring Boot开发web项目(Gradle版)

7、在build.gradle中添加对thymeleaf的依赖。


            Spring Boot开发web项目(Gradle版)

8、通过main工程,启动项目,访问。

            Spring Boot开发web项目(Gradle版)

9、对应 的github的地址为:https://github.com/longshenaa/demo