zoukankan      html  css  js  c++  java
  • JPA多数源的一种方式

      JPA设置多数据源有很多种方法,有一种古老而有效的方法,可以让不同目录下建的DAO到不同的数据源,只在xml里设置一次就可以,其核心逻辑是:<jpa:repositories>  标签

    <!-- 基本数据源定义 -->
    <jpa:repositories base-package="cn.jiashubing,com.jiashubing"
        transaction-manager-ref="transactionManager"
        entity-manager-factory-ref="entityManagerFactory"
                      repository-impl-postfix="Impl"/>
    
    <!-- 日志数据源定义 -->
    <jpa:repositories base-package="cn.jiashubing.log,com.jiashubing.log"
        transaction-manager-ref="transactionManager_log"
        entity-manager-factory-ref="entityManagerFactory_log"
        repository-impl-postfix="Impl" />

    base-package 指向不同的路径

    transactionManager、entityManagerFactory、transactionManager_log、entityManagerFactory_log 的定义参考网上资料

    原创文章,欢迎转载,转载请注明出处!

  • 相关阅读:
    第三次作业
    第二实验
    第一次作业
    yii2 Modal的使用
    yii2 显示列表字段 的技巧
    YII2在使用activeForm设置默认值
    html基础1
    tomcat+redis实现session共享缓存
    linux部署mongodb及基本操作
    hadoop 常用命令
  • 原文地址:https://www.cnblogs.com/acm-bingzi/p/jpa_mu.html
Copyright © 2011-2022 走看看