【问题标题】:Spring Boot will auto configure JPA transaction managerSpring Boot 将自动配置 JPA 事务管理器
【发布时间】:2018-03-13 03:41:20
【问题描述】:

我正在创建与单个 DB 交互的 Spring Boot 应用程序。我使用了 @EnableAutoconfiguration@EnableTransactionManagement 并提供了 spring-data-jpa

我想使用 Hibernate JPA 供应商及其方言。 spring 会自动配置这个和 JPA transactionmanager 还是我需要手动注册这些 bean。

【问题讨论】:

    标签: spring-boot spring-data-jpa


    【解决方案1】:

    您需要在 application.yml 中提供这个最小的 jpa 配置,以便 spring 可以配置休眠。如果您使用application.properties 文件,请相应更改属性格式。

    spring:
        datasource:
            url: jdbc:mysql://<mysql_db_url_here>
            username: <mysql_username>
            password: <mysql_pwd>
            driver-class-name: <db_driver_class> (e.g. com.mysql.jdbc.Driver)
    
        jpa:
            database-platform: <db_dilect_class> (e.g. org.hibernate.dialect.MySQL5Dialect)
    

    【讨论】:

      猜你喜欢
      • 2015-04-24
      • 1970-01-01
      • 2017-12-23
      • 2017-07-30
      • 1970-01-01
      • 2017-05-29
      • 2010-10-18
      • 2018-12-30
      相关资源
      最近更新 更多