一,JPA 方式

POM

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>

application.yml

spring:
  application:
    name: shipcenter
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://xxxxx:5432/leadtrans
    username: xxx
    password: xxx
  jpa:
    generate-ddl: false
    hibernate:
      ddl-auto: none
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    database: postgresql
    show-sql: false

二,Mybatis-plus

POM

<dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>

application.yml

spring:
  application:
    name: shipcenter
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://xxxxx:5432/leadtrans
    username: xxxx
    password: xxxx

mybatis-plus:
  configuration:
    map-underscore-to-camel-case: false   #关闭驼峰转下划线
  global-config:
    db-config:
      update-strategy: ignored    #null也会更新

PS:设置一下编码,不然中文注释可能会报错

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。