Announcement Announcement Module
No announcement yet.
Spring + myBatis - Result Maps collection already contains value problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + myBatis - Result Maps collection already contains value problem

    I am having a problem integrating myBatis with Spring.

    I followed the 3-part tutorial here:

    And when I deploy it to my web server (weblogic) I get the error:

    Result Maps collection already contains value for com.test.TestService.testResultMap

    I think Spring is creating the thing twice, but I dont know why it is doing that.

    In the logs, I see that prior to this error there is this output: - Creating MapperFactoryBean with name 'testService' and 'com.test.TestService' mapperInterface.

    No errors here, seems it loads just fine.

    Then some other debug stuff before finally seeing the error this thread is about, associated with the class: - Error while adding the mapper 'interface com.test.TestService' to configuration.

    in the stack trace I see this gets called by spring's AbstractAutowireCapableBeanFactory

    So what could be going on? Why is Spring creating my service twice resulting in this error?

    I just have one spring config xml entry where I use MyBatis MapperScannerConfigurer and pass it my service's package name. It looks like the first debug output where it create the TestService first time fine is from this. The second time it's created is from some Autowired config, so I look in my class, which is a Controller and see:

    public class TestController {

    private TestService testService;

    public TestController (TestService testService) {
    this.testService = testService;

    I have no other configurations or annotations referencing TestService anywhere in my project.