springboot-thymeleaf 快速开发模板

idea springboot initializr 创建springboot项目

填好项目的基本信息maven

选择你需要依赖模块




下一步后等待下载~

若还需要再次依赖别的jar包,可以在下面地址找

    https://mvnrepository.com/

在application.properties(yml)填写必要信息

server:
  port: 8080
### 需要别的也可以找

resources/templates 文件夹下编写index.html编写前端页面

默认boot会放行该文件夹下的静态以 html结尾的文件

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>abc</title>
    <link th:href="@{/webjars/bootstrap/4.4.1/css/bootstrap.css}">
    <link th:href="@{/webjars/jquery/3.4.1/jquery.js}">
</head>
<body>
hello
</body>
</html>

引入前端的文件,boot推荐使用webjars来引入前端的文件,可以在下面地址找需要的前端样式和js文件,在maven,pom文件中添加

https://www.webjars.org/

引用的话类似于这样子

    <link th:href="@{/webjars/bootstrap/4.4.1/css/bootstrap.css}">
    <link th:href="@{/webjars/jquery/3.4.1/jquery.js}">

在项目下的位置

---
之后是热部署工具配置idea

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>


完毕~

猜你喜欢

转载自www.cnblogs.com/iullor/p/12205963.html