Giter Site home page Giter Site logo

Comments (3)

lishuanghe214 avatar lishuanghe214 commented on May 17, 2024

我的没有xml
@bean
//@ConfigurationProperties(prefix = "mybatis")
public SqlSessionFactoryBean sqlSessionFactoryBean() {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
// Here to config mybatis
// sqlSessionFactoryBean.setTypeAliasesPackage("cn.com.hellowood.dynamicdatasource.mapper");
// sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("mappers/**Mapper.xml"));
// Here is very important, if don't config this, will can't switch datasource
// put all datasource into SqlSessionFactoryBean, then will autoconfig SqlSessionFactory
sqlSessionFactoryBean.setDataSource(dynamicDataSource());
return sqlSessionFactoryBean;
}

from springboot-dynamicdatasource.

lishuanghe214 avatar lishuanghe214 commented on May 17, 2024

Switch DataSource to [slave] in Method [List com.weiyin.streetlamp.menu.dao.MenuDao.listAll()]
2020-11-03 12:36:43.669 [http-nio-0.0.0.0-8001-exec-7] INFO c.w.s.dynamicdatasource.DynamicRoutingDataSource - Current DataSource is [slave]
2020-11-03 12:36:43.674 [http-nio-0.0.0.0-8001-exec-7] INFO c.w.s.dynamicdatasource.DynamicDataSourceAspect - Restore DataSource to [master] in Method [List com.weiyin.streetlamp.menu.dao.MenuDao.listAll()]
控制台信息是这样,但是读不到数据

from springboot-dynamicdatasource.

helloworlde avatar helloworlde commented on May 17, 2024

You can reference this document https://github.com/helloworlde/SpringBoot-DynamicDataSource/blob/master/Issues.md

from springboot-dynamicdatasource.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.