spring boot整合mybatis、jsp、thymeleaf的依赖和基本配置汇总

spring boot整合mybatis、jsp、thymeleaf的依赖和基本配置汇总

  1. 依赖添加(基本依赖)

    
    
        4.0.0
        
            org.springframework.boot
            spring-boot-starter-parent
            2.2.6.RELEASE
             
        
        com.shj
        springdemo
        0.0.1-SNAPSHOT
        war
        springdemo
        Demo project for Spring Boot
    
        
            1.8
        
    
        
            
                org.springframework.boot
                spring-boot-starter-web
            
    
            
                org.springframework.boot
                spring-boot-devtools
                runtime
                true
            
            
                org.projectlombok
                lombok
                true
            
            
                org.springframework.boot
                spring-boot-starter-tomcat
                provided
            
            
                org.springframework.boot
                spring-boot-starter-test
                test
                
                    
                        org.junit.vintage
                        junit-vintage-engine
                    
                
            
        
    
        
            
                
                    org.springframework.boot
                    spring-boot-maven-plugin
                
            
        
    
    
    
  2. 整合mybatis相关的依赖及application.yml配置

    
    
        org.mybatis.spring.boot
        mybatis-spring-boot-starter
        1.2.1
    
    
    
        com.alibaba
        druid
        1.0.28
    
    
    
        mysql
        mysql-connector-java
    
    
    server:
      port: 8888
    spring:
      datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        url: jdbc:mysql://localhost:3307/school?useSSL=true&serverTimezone=UTC&characterEncoding=UTF-8
        driver-class-name: com.mysql.jdbc.Driver
        username: root
        password: 970809
    mybatis:
      type-aliases-package: com.shj.entity
      mapper-locations: classpath:mapper/*Dao.xml
    
  3. 整合jsp的依赖及application.yml配置

    
    
    
        javax.servlet
        javax.servlet-api
        provided
    
    
    
    
        javax.servlet
        jstl
    
    
    
    
        org.springframework.boot
        spring-boot-starter-tomcat
        provided
    
    
    
    
        org.apache.tomcat.embed
        tomcat-embed-jasper
        provided
    
    
    mvc:
      view:
        prefix: /WEB-INF/jsp/
        suffix: .jsp
    
  4. 整合thymeleaf

    
    
        org.springframework.boot
        spring-boot-starter-thymeleaf
    
    
    thymeleaf:
      cache: false        # 开发时关闭缓存,否则无法实时看到页面效果
      mode: LEGACYHTML5   # 使用非严格的HTML标准
      encoding: UTF-8
    

你可能感兴趣的:(spring boot整合mybatis、jsp、thymeleaf的依赖和基本配置汇总)