#SpringBoot + Thymeleaf + MySQLの+ MP

SpringBoot + Thymeleaf + MP

設定に依存:

        <!-- spring boot 的父类 -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.1.RELEASE</version>
</parent>

<dependencies>

    <!-- spring web 依赖 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- spring test 测试 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>

    <!-- mysql 驱动 -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.37</version>
    </dependency>

    <!-- mybatisplus与springboot整合  如果版本过低需要导入 mp的依赖 -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.2.0</version>
    </dependency>


    <!-- mybatis-plus 依赖 -->
<!--        <dependency>-->
<!--            <groupId>com.baomidou</groupId>-->
<!--            <artifactId>mybatis-plus</artifactId>-->
<!--            <version>3.2.0</version>-->
<!--        </dependency>-->

    <!-- spring 整合 mp   分页工具类  版本2一下需要自定义 -->
<!--        <dependency>-->
<!--            <groupId>com.github.pagehelper</groupId>-->
<!--            <artifactId>pagehelper-spring-boot-starter</artifactId>-->
<!--            <version>1.2.3</version>-->
<!--        </dependency>-->


    <!-- thymeleaf页面  -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    <!-- 热启动 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    
</dependencies>

情報をプロフィール:

server:
  port: 8081 #端口号

spring:
  application:
    name: user  #程序名称
  datasource:    #数据库连接基本四项
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/mp?allowMultiQueries=true
    username: root
    password: 123456
  main:
    allow-bean-definition-overriding: true # 覆盖相同的bean
  thymeleaf: #thymeleaf前端
    cache: false #是否进行数据缓存 选择false 便于使用热部署  必须配置
    prefix: classpath:/templates/ #前缀
    suffix: .html #后缀
    mode: LEGACYHTML5  #模块类型  LEGACYHTML5 必须配置
    encoding: UTF-8 #编码类型   必须配置
    servlet:
      content-type: text/html #文件类型
    enable-spring-el-compiler: true #

mybatis:
  typeAliasesPackage: com.web.mp.pojo #扫描实体类的包
  mapperLocations: classpath:mappers/*.xml  #mapper配置文件扫描

mybatis-plus:
  configuration:
    map-underscore-to-camel-case: false   # 小驼峰和下换线的转换

ピット:

  • 簡単かを認識しないように、フォームで書かthymeleafプレフィックスが好ましく配置されている1.

     prefix: classpath:/templates/

おすすめ

転載: www.cnblogs.com/yizhichenfen/p/11913639.html