您的位置:首页 > 编程语言 > Java开发

记录分享公司Spring data相关配置

2016-05-16 15:22 162 查看

起因

  公司Spring Data相关的配置还是有点意思的,不过蛮复杂的...XML很多...我不太喜欢强行记住....所以我打算记录一下配置的大致思路和结构,以后可能会有用....

总体结构

<jpa:repositories base-package="gov.gt3.iitms.sbf"
entity-manager-factory-ref="hxEntityManagerFactory"
transaction-manager-ref="hxTransactionManager"
factory-class="org.springframework.data.jpa.repository.support.CustomRepositoryFactoryBean">
<repository:include-filter type="regex"
expression="gov\.gt3\.iitms\.sbf\.sb\.repository\.[^.]*Repository" />
<repository:include-filter type="regex"
expression="gov\.gt3\.iitms\.sbf\.sb\.batch\.standard\.plkk\.repository\.[^.]*Repository" />
</jpa:repositories>

<jpa:repositories base-package="gov.gt3.iitms.sbf"
entity-manager-factory-ref="zgEntityManagerFactory"
transaction-manager-ref="zgTransactionManager"
factory-class="org.springframework.data.jpa.repository.support.CustomRepositoryFactoryBean">
<repository:include-filter type="regex"
expression="gov\.gt3\.iitms\.sbf\.sb\.repository\.cxtj\.[^.]*Repository" />
</jpa:repositories>


View Code
比如我这里要用到2个数据源..那除了这2个数据源对应的entity在配置jpa entity manager里配置外(前面提到过)..这里还需要配置需要加载的repository在哪里...

也就是说你可以1个entity.java对应2个数据源的2个repository....

反正这个模块要用到几个数据源,这里就加载这几个数据源要用到的repository...repository相当于是数据存储的路径方式,所以是跟着数据源走的...

总结

也没啥好总结的...上面就是公司的主要用法...自己简单玩玩的话似乎不需要这么复杂...不知道其他公司是怎么配置的...等我有新的发现的时候再补充说明吧...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: