springboot手动搭建教程(三分钟简易搭建springboot项目详解)
springboot手动搭建教程(三分钟简易搭建springboot项目详解)<groupId>org.springframework.boot</groupId> <dependency> 本例采用maven架构,下载倒入的结构如下: ***对于maven项目首先需要分析的就是pom文件,此处的pom文件如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <m
一:快速创建springboot项目主要对springboot做引导性讲解,帮助快速搭建boot项目,可略过boot基础。
生成springboot除过通过传统的eclipse,idea这些高效的开发工具之外,spring也为饿哦们提供了一个更为便捷的途径,一种脱离了对开发工具依赖的方式。
首先 打开浏览器,输入: http://start.spring.io (spring所有的产品请查看 spring.io官网浏览学习),该搭建方式只是最基础的搭建。
如上图,选择需要的配置后点击下载即可,下载后的文件解压后倒入开发工具即可使用。
本例采用maven架构,下载倒入的结构如下:
***对于maven项目首先需要分析的就是pom文件,此处的pom文件如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.zxyf</groupId> <artifactId>boots</artifactId> <version>0.0.1-SNAPSHOT</version> <name>boots</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
一、 因为springboot默认对thymeleaf是友好的,此处可以直接在pom中添加如下配置,增加对thymeleaf的支持;
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
二、application.properties添加设置,开发环境设置Thymeleaf缓存不可用
#Thymeleaf编码
spring.thymeleaf.encoding=UTF-8
#热部署静态文件 指不对Thymeleaf模板进行缓存
#这样在开发阶段修改模板后 就能在浏览器中及时看到修改后页面效果
spring.thymeleaf.cache=false
#使用HTML5标准
spring.thymeleaf.mode=HTML5
总结: springboot使用thymeleaf使用四步骤:
总共四步:jar 引入 、控制器参数传递 、 html标签引入 、 Thymeleaf 缓存设置
完成以上配置,即可编写前台页面与后台实现通信。