shardingsphere
shardingsphere copied to clipboard
Project startup error Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
For English only, other languages will not accept.
Before report a bug, make sure you have:
Searched open and closed GitHub issues. Read documentation: ShardingSphere Doc. Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Which version of ShardingSphere did you use? 5.1.1
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy? ShardingSphere-JDBC
Expected behavior Normal startup of the project
Actual behavior Project startup error
Reason analyze (If you can) Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
- You didn't give a minimal reproducible example. ShardingSphere configuration doesn't use anything like sqlSessionFactory.
可能是 你配置了多个datasource,但是没指定shardinsphere创建的datasource为Primary
Hello , this issue has not received a reply for several days. This issue is supposed to be closed.
I had the same problem. Several of the same issues were found in Issues, but none of them were actually solved, even the ones that were closed. Why mybatis can be assembled successfully if you comment out the configuration of rules? This should not be due to the sequence of automatic assembly.
我有同样的问题。在issue里类似的问题好几个,但是没有一个是真正解决了的,即使是那些关闭了的。为什么注释掉rules的配置,mybatis就能装配成功。这不该是自动装配的先后顺序导致的.
Hi @pengxianggui, can you provide a demo to help reproduce this problem?
Hi @pengxianggui, can you provide a demo to help reproduce this problem?
Thank you for your attention! Giving a full demo is a bit of a hassle, and I believe it will be easier to reproduce this problem if you rely on this package:
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
</dependency>
This is my dependency analysis, for mybatis:
My project is built on springboot 2.2.9
@pengxianggui
- I cannot reproduce your problem using ShardingSphere JDBC under pure JDBC 4.1 API. Without any context, I'm inclined to think that this is a compatibility issue of
tk.mybatis:mapper-spring-boot-starter
with your particular Mybatis version.
- I cannot reproduce your problem using ShardingSphere JDBC under pure JDBC 4.1 API. Without any context, I'm inclined to think that this is a compatibility issue of
tk.mybatis:mapper-spring-boot-starter
with your particular Mybatis version.
@linghengqian Thank you for your attention!
Unfortunately, I changed tkmapper to mybatisplus, but I got the same result. If I comment out the rules configuration, through breakpoint debugging, it will execute Mybatis related AutoConfiguration, but if I set rules, these AutoConfiguration, Even the DataSourceAutoConfiguration won't assembly.
This is my dependency analysis, for mybatisplus, It couldn't be simpler:
很遗憾,我把tkmapper换成mybatisplus, 但得到的结果是样的。如果我注释掉rules配置,通过断点调试, 程序能顺利执行Mybatis的相关AutoConfiguration, 但如果我设置rules,这些AutoConfiguration,甚至连DataSourceAutoConfiguration都不会装配。 这是我关于mybatisplus的依赖分析,不能更简单了。
@pengxianggui If you don't provide the full stack and unittests, it's a black box. I tested Mybatis Plus earlier and everything works fine.
@pengxianggui If you don't provide the full stack and unittests, it's a black box. I tested Mybatis Plus earlier and everything works fine.
@linghengqian Thanks for you attention! I fixed the problem, which was caused by another package I relied on.
By the way, If there are any usage problems, where can we communicate?
@pengxianggui If you don't provide the full stack and unittests, it's a black box. I tested Mybatis Plus earlier and everything works fine.
@linghengqian Thanks for you attention! I fixed the problem, which was caused by another package I relied on.
By the way, If there are any usage problems, where can we communicate?
- For the most part, all communication happens on Github Issues.
@pengxianggui If you don't provide the full stack and unittests, it's a black box. I tested Mybatis Plus earlier and everything works fine.
@linghengqian Thanks for you attention! I fixed the problem, which was caused by another package I relied on. By the way, If there are any usage problems, where can we communicate?
- For the most part, all communication happens on Github Issues.
All right. I have a question, take the official demo for example.
I used the binding table to avoid the Cartesian product, so I have to use orderId as the sharding field, but in reality, I need to sharding by year, so I should take order_time as the sharding field. Because there are only interval conditions for orderTime in the paging query condition.
How can I avoid Cartesian products in associative table queries while using orderTime sharding? Thanks for your answer!
好吧。我有一个问题,以官方的demo为例。 我使用了绑定表避免笛卡尔积,因此我必须使用orderId作为分片字段,但是实际情况,我需要按年份分片,我应该取order_time作为分片字段。因为分页查询条件里只有针对orderTime的区间条件。 我如何在使用orderTime分片的同时,又能在关联表查询中避免笛卡尔积呢? 感谢您的解答!
@pengxianggui
- I don't seem quite sure what the table structure looks like for the example you're talking about. I'm on my Christmas break, you can open a new question issue.
- Christmas
well, happy christmas!
Resolved.