java - 如何在spring + mybatis 下进行数据库读写分离
大家讲道理
大家讲道理 2017-04-18 09:46:36
0
2
333

如题。

Dao层代码由mybatis-generator-core自动生成,并由spring管理,调用的时候类似这样:

@Service("articleService") public class ArticleServiceImpl implements ArticleService { @Autowired ArticleMapper articleMapper; public void update(Integer id){ //一个方法里可能有查询和更新 Article article = articleMapper.selectByPrimaryKey(id); articleMapper.updateByPrimaryKeySelective(article); } }

如何通过配置实现读写分离,希望对现有代码框架影响小?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all (2)
阿神

Configure several more dataSources in the spring configuration dataSource. Use the method name to determine whether it is a reading library or a writing library, similar to transaction control.

    洪涛

    You can refer to this article, which is very detailed.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!