SpringBoot:阿里数据源配置、JPA显示sql语句、格式化JPA查询的sql语句

本文介绍如何在Spring Data JPA中配置Hibernate参数,包括显示SQL和格式化SQL等设置,适用于微服务架构下的数据库操作优化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

1 数据源和JPA配置

  1.1 显示sql配置和格式化sql配置

    者两个配置都是属于hibernate的配置,但是springdatajpa给我们简化了;所有hibernate的配置都在jpa下面的properties中;若果直接配置到jpa下面可能不会生效

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/  # 注册中心
  instance:
    hostname: productClient
spring:
  application:
    name: product

  datasource:
    url: jdbc:mysql://xxxxx:3306/spring_cloud_sell?useUnicode=true&characterEncoding=UTF-8&useSSL=false
#    url: jdbc:mysql://xxxxx:3306/dev?useUnicode=true&characterEncoding=UTF-8&&useSSL=false
#    url: jdbc:mysql://xxxxx:3306/qcbx?useUnicode=true&characterEncoding=UTF-8&&useSSL=false
    driver-class-name: com.mysql.jdbc.Driver
#    username: root
#    password: uAiqwVwjJ8-i
    username: dev
    password: Dev-182838
  jpa:
    properties:
          hibernate:
            format_sql: true
            show_sql: true
View Code

 

 

  

转载于:https://www.cnblogs.com/NeverCtrl-C/p/9355293.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值