spring icon indicating copy to clipboard operation
spring copied to clipboard

How to enable mybatis scan after bean post (just when the applicationContext initialized)

Open bwzhang2011 opened this issue 11 years ago • 1 comments

mybatis provide simple cache integration defined in mybatis mapper xml. but it has some problem that the cache integrated sometimes is not initialized completed while the application context is loading. if we bring in some @Postconstruct annotation to construct the spring bean it will throw nullpointerException while the cache instance could not be found. so how could I enable the beanpost way for mybatis especially for @mapperscan support. and through some configuration, the mybatis will invoke the initialize operation after the applicationContext completed. I just remembered some article referred such before but I could not know how to invoke that. so hope mybatis team could help me. for the cache instance sometimes is build through spring.

bwzhang2011 avatar Nov 17 '14 03:11 bwzhang2011

@emacarron, would you mind sparing some time to take a look at this ? as some cache implementation is too simple that could not satisfy the actual use cases. so when encounter such problem that the cache instance has not been initialized completely through the container, when calling the mapper with the cache configuration support it will throw null pointer Exception for the cache reference has not been done. I just know where the point but I could not how to hack it just make the cache reference done after the context initialized.

bwzhang2011 avatar Nov 17 '14 22:11 bwzhang2011