Git Product home page Git Product logo

spring-boot-mybatis-mysql-write-read's Issues

范例有错误

mysql主从复制,读写分离,启用事务管理,在service层做切面时,controller调用的每个service方法都必须指明数据源注解。AopContext.currentProxy()固然可以获取数据源,可是在controller去调用service不带注解的方法(如wirteAndRead(),readAndWirte())的时候会先判断数据源,再往下执行。这时候,该方法将会出现未指定明确数据源的报错。也就是在执行wirteAndRead和readAndWirte的里面的代码前已经报错。
可以为service指定数据源,也可以在数据源配置中修改”typeKey 为空时指定默认数据源“。

mapper.xml的问题

dao层query方法List query(@param("userName")String userName);
返回的是User集合,而mapper.xml写的返回是User
是不是写错了

@ConfigurationProperties无法注入数据源

@bean(name = "readDataSource01")
@ConfigurationProperties(prefix = "spring.druid.read01")
public DataSource readDataSourceOne() {
log.info("-------------------- read01 DataSourceOne init ---------------------");
return DataSourceBuilder.create().type(dataSourceType).build();
}
dug这里使用@ConfigurationProperties(prefix = "spring.druid.read01")并没有将数据库配置注入datasource里面。本来我用的是prefix = "spring.datasource.read01"但是这样会报错druid url not set,所以我换成"spring.druid.read01",但是会报错WrongArgumentException: The database URL cannot be null。 debug发现没有将数据库配置注入datasource里面。

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.