sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.96k stars 1.26k forks source link

sofaboot模块作为业务层,dao层如何处理呢?每个模块中都配置datasource么? #207

Closed CharlesSong closed 6 years ago

CharlesSong commented 6 years ago

sofaboot模块作为业务层,dao层如何处理呢?每个模块中都配置datasource么?感觉示例太少了,建议给写标准指引

QilongZhang commented 6 years ago

@CharlesSong 有两种方式解决解决问题: 1、 设置 dao 层模块为其他模块的父上下文,在其他模块可以通过spring原生注入的方式引用 http://www.sofastack.tech/sofa-boot/docs/SOFABoot-Module 2、把 datasource 发布成 jvm 服务,在其他模块引用

感谢反馈,我们稍后会增加演示工程。

QilongZhang commented 6 years ago

@CharlesSong 使用 h2database 简单写了一个数据源的使用demo,请参考 https://github.com/alipay/sofa-boot/tree/master/sofaboot-samples/sofaboot-sample-standard

CharlesSong commented 6 years ago

@QilongZhang 感谢