UnsatisfiedDependencyException when creating MongoTemplate bean

后端 未结 4 1635
南方客
南方客 2021-01-25 16:48

Using the Mongobee for Migration with spring mongo

 plugins {
    id \'org.springframework.boot\' version \'2.3.1.RELEASE\'
    id \'io.spring.dependency-manageme         


        
4条回答
  •  清歌不尽
    2021-01-25 17:14

    The version of Spring Data MongoDB included in Spring Boot 2.3 uses version 4 of Mongo's Driver, but Mongobee depends on version 3. The two versions have different Maven coordinates (group ID and artifact ID) so you end up with both of them on the classpath. This leads to some code from version 4 of the driver using code from version 3 and a NoSuchFieldError results.

    You can avoid the problem by excluding the Mongo Driver from the Mongobee dependency:

    compile('com.github.mongobee:mongobee:0.13') {
        exclude group: 'org.mongodb'
    }
    

提交回复
热议问题