spring data jpa 数据库连接配置要点整理

  • mysql
spring:
	datasource:
		driver-class-name: com.mysql.cj.jdbc.Driver
		url: jdbc:mysql://${ds.host}/${ds.db}?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    hikari:
      connection-test-query: select 1
	jpa:
		database-platform: org.hibernate.dialect.MySQLDialect
  • oracle
spring:
	datasource:
		driver-class-name: oracle.jdbc.OracleDriver
		url: jdbc:oracle:thin:@//${ds.host}/${ds.service-name}
		# sid模式 url: jdbc:oracle:thin:@${ds.host}:${ds.sid}
    hikari:
      connection-test-query: select 1 from dual
	jpa:
		database-platform: org.hibernate.dialect.OraclecDialect
  • mssql
spring:
	datasource:
		driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
		url: jdbc:sqlserver://${ds.host};instanceName=${ds.instance};DatabaseName=${ds.db}
    hikari:
      connection-test-query: select 1
	jpa:
		database-platform: org.hibernate.dialect.SQLServerDialect

posted on 2020-10-27 16:10  路过君  阅读(772)  评论(0编辑  收藏  举报

导航