mysql
- spring.jpa.database=MYSQL
- spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
- spring.datasource.driver-class-name=com.mysql.jdbc.Driver
- spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mydbname?useSSL=false
- spring.datasource.username=user1
- spring.datasource.password=user1
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.34</version>
- </dependency>
oracle
- spring.jpa.database = oracle
- spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.Oracle10gDialect
- spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver
- spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:xe
- spring.datasource.username=user1
- spring.datasource.password=user1
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc7</artifactId>
- <version>12.1.0.2.0</version>
- </dependency>
sqlserver
- spring.jpa.database = sql_server
- spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.SQLServerDialect
- spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
- spring.datasource.url=jdbc:sqlserver://127.0.0.1:1433;databaseName=mydbname
- spring.datasource.username=user1
- spring.datasource.password=user1
- <dependency>
- <groupId>com.microsoft.sqlserver</groupId>
- <artifactId>mssql-jdbc</artifactId>
- <version>6.1.0.jre8</version>
- </dependency>
连接池设置
- spring.datasource.max-active=20
- spring.datasource.max-idle=8
- spring.datasource.min-idle=8
- spring.datasource.initial-size=10
- spring.jpa.show-sql=true
- # Hibernate ddl auto (create, create-drop, update)
- spring.jpa.hibernate.ddl-auto=update
- # physical_naming_strategy 避免java属性映射到数据库字段时,驼峰转下划线
- spring.jpa.properties.hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
各种数据库对应的validationQuery
- # sqlserver
- spring.datasource.validationQuery=SELECT 1
- # oracle
- spring.datasource.validationQuery=SELECT 1 FROM DUAL
- # mysql
- spring.datasource.validationQuery=SELECT 1 FROM DUAL