Spring data jpa simple configuration of springboot

spring:
  jpa:
    hibernate:
      ddl-auto: update
    database: mysql
    show-sql: true
    generate-ddl: true
  datasource:
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/quickcode?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull

Here I use the yml syntax to configure, which is very similar to the properties file, so I won't introduce it much.

spring data jpa is implemented using hibernate. Configuration properties are not described much.

Briefly talk about the url of jdbc, in fact, spring can automatically analyze the driver class through the url, that is to say, it is possible to configure the driver-class-name without configuration. There is a characterEncoding behind the url, which is the database encoding, and useSSL, which is a secure connection, so I won't introduce it much. Sometimes an exception is thrown saying that it cannot connect to the database using ssl, you can set this to false. zeroDateTimeBehavior, this is the processing method for the column value of timestamp type for the low version of the database. The lower version of the database will set the value of this thing to 0000-00-00 00:00:00 by default. This is because java cannot parse this date format, resulting in an error. Setting this to convertToNull will convert dates in this format to null. This exception will not exist, and this problem no longer exists for the new version of mysql.

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324036975&siteId=291194637