SpringBoot+jpa适配国产达梦数据库

  依赖:spring-boot-starter-data-jpa等其他Spring依赖版本都是2.1.5

        <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>Dm8JdbcDriver18</artifactId>
            <version>8.1.1.49</version>
        </dependency>
        <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>DmDialect-for-hibernate5.3</artifactId>
            <version>8.1.1.49</version>
        </dependency>
        <dependency>
            <!--注意:只有这个版本的hibernate兼容达梦数据库 -->
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.3.18.Final</version>
        </dependency>

  对应application.properties配置:

spring.datasource.url=jdbc:dm://ip:5236/
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.driver-class-name=dm.jdbc.driver.DmDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=false
#方言
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DmDialect
spring.jpa.database-platform=org.hibernate.dialect.DmDialect
spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.properties.hibernate.show_sql=true
#模式名称
spring.jpa.properties.hibernate.default_schema=ispatial
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
spring.data.redis.repositories.enabled = false
spring.datasource.dbcp2.test-on-borrow=true
spring.datasource.dbcp2.validation-query=SELECT 1

  注:国产达梦数据库的SQL跟Oracle差不多,如果想手动创建表,若有对应Oracle SQL可直接运行创建。

posted @ 2022-02-17 14:01  码猿手  阅读(2068)  评论(0编辑  收藏  举报
Live2D