1. 程式人生 > >spring boot+spring data jpa+gradle+mysql配置問題

spring boot+spring data jpa+gradle+mysql配置問題

cto one com ons pri -- 裏的 prope tail

1、gradle/wrapper/gradle-wrapper裏要設置正確本地的gradle目錄(我用的是4)

2、在src目錄裏的application.properties文件裏,可以這樣設置

# Thymeleaf 編碼
spring.thymeleaf.encoding=UTF-8
# 熱部署靜態文件
spring.thymeleaf.cache=false
# 使用HTML5標準
spring.thymeleaf.mode=HTML5
# 使用 H2 控制臺
#spring.h2.console.enabled=true
# DataSource
spring.datasource.url=jdbc:mysql://localhost/blog?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8

spring.datasource.username=root

spring.datasource.password=123456

#如果mysql是5.*的,那麽要用第一句,如果是6.*的,用第二句

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# JPA

#一開始沒加這句,一直有錯

spring.jpa.database=mysql
spring.jpa.show-sql = true

#這句是hibernate自動drop-create表的,其實不需要

#spring.jpa.hibernate.ddl-auto=create-drop

3、接下來修改build.gradle,我的電腦裏的mysql是5.*的,所以要寫這樣的依賴:

compile(‘mysql:mysql-connector-java:5.1.24‘)

4、editplus是編輯神器,不會出現編碼錯誤導致gradle build時出錯的問題
---------------------
作者:magicrp
來源:CSDN
原文:https://blog.csdn.net/magicrp/article/details/80986456
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!

spring boot+spring data jpa+gradle+mysql配置問題