2020-03-10(SpringBoot)

Thymeleaf模版学习

2020/3/10 13:39:46


Thymeleaf模板使用

1. 添加额外依赖
转载自
https://www.funtl.com/zh/spring-boot-thymeleaf

 
     net.sourceforge.nekohtml
     nekohtml
     1.9.22
 

spring:
  thymeleaf:
    cache: false # 开发时关闭缓存,不然没法看到实时页面
    mode: LEGACYHTML5 # 用非严格的 HTML
    encoding: UTF-8
    servlet:
      content-type: text/html

2. 优点

实现动静结合

SpringBoot整合MyBaits

转载自
https://www.funtl.com/zh/spring-boot-mybatis

1. 整合Druid

--druid依赖------------------

    com.alibaba
    druid-spring-boot-starter
    1.1.10


--mysql连接驱动依赖------------

    mysql
    mysql-connector-java
    runtime


--application.yml配置----------
spring:
  datasource:
    druid:
      url: jdbc:mysql://ip:port/dbname?useUnicode=true&characterEncoding=utf-8&useSSL=false
      username: root
      password: root
      initial-size: 1
      min-idle: 1
      max-active: 20
      test-on-borrow: true
      # MySQL 8.x: com.mysql.cj.jdbc.Driver
      driver-class-name: com.mysql.jdbc.Driver

2. 整合tk.MyBatis
tk.MyBatis 继承 MyBatis ,比MyBatis更加方面

----依赖-------

    tk.mybatis
    mapper-spring-boot-starter
    2.0.2


----application.yml配置
mybatis:
    type-aliases-package: 实体类的存放路径,如:com.lth.springboot.mybatis.entity
    mapper-locations: classpath:mapper/*.xml

----创建一个通用的父级接口----
/**
 * 自己的 Mapper
 * 特别注意,该接口不能被扫描到,否则会出错,在src/main/java下创建
 * 

Title: MyMapper

*

Description:

public interface MyMapper extends Mapper, MySqlMapper { }

3. 添加MyBayis分页插件(PageHelper)


    com.github.pagehelper
    pagehelper-spring-boot-starter
    1.2.5


----使用Maven插件生成代码----

    
        
            org.mybatis.generator
            mybatis-generator-maven-plugin
            1.3.5
            
                ${basedir}/src/main/resources/generator/generatorConfig.xml
                true
                true
            
            
                
                    mysql
                    mysql-connector-java
                    ${mysql.version}
                
                
                    tk.mybatis
                    mapper
                    3.4.4
                
            
        
    


----generator/generator.xml----




    
    

    
        
        
        
        
        
            
        

        
        
        

        
        

        
        

        
        

        
        
        
----jdbc.properties---- # MySQL 8.x: com.mysql.cj.jdbc.Driver jdbc.driverClass=com.mysql.jdbc.Driver jdbc.connectionURL=jdbc:mysql://ip:port/dbname?useUnicode=true&characterEncoding=utf-8&useSSL=false jdbc.username=root jdbc.password=root

你可能感兴趣的:(2020-03-10(SpringBoot))