arhs / spring-cache-mongodb

Spring Cache implementation based on MongoDB
MIT License
17 stars 14 forks source link

How to use spring-cache-mongodb with spring-data-mongodb-reactive #8

Open devansh-dalal opened 3 years ago

devansh-dalal commented 3 years ago

We are using spring-data-mongodb reactive in our spring application. when tried to use spring-cache-mongodb with it, fails:

021-03-06 22:15:39.482 DEBUG 59911 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : Application failed to start due to an exception

java.lang.NoSuchMethodError: 'com.mongodb.DBCollection org.springframework.data.mongodb.core.MongoTemplate.getCollection(java.lang.String)'
    at com.arhs.spring.cache.mongo.MongoCache.creationCollection(MongoCache.java:119) ~[spring-cache-mongodb-1.0.1.jar:1.0.1]
    at com.arhs.spring.cache.mongo.MongoCache.initialize(MongoCache.java:299) ~[spring-cache-mongodb-1.0.1.jar:1.0.1]
    at com.arhs.spring.cache.mongo.MongoCache.<init>(MongoCache.java:115) ~[spring-cache-mongodb-1.0.1.jar:1.0.1]
    at com.arhs.spring.cache.mongo.MongoCacheBuilder.build(MongoCacheBuilder.java:82) ~[spring-cache-mongodb-1.0.1.jar:1.0.1]
    at com.arhs.spring.cache.mongo.MongoCacheManager.loadCaches(MongoCacheManager.java:56) ~[spring-cache-mongodb-1.0.1.jar:1.0.1]

These are the dependencies

dependencies {
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-mongodb-reactive', version: '2.4.3'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-mongodb', version: '2.4.3'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.4.3'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.4.3'
    implementation group: 'org.la4j', name: 'la4j', version: '0.6.0'
    implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.4'
    implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
//  implementation group: 'com.arhs-group', name: 'spring-cache-mongodb', version: '1.0.1'
    compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.18'
    annotationProcessor "org.projectlombok:lombok"
}

I have a hunch that it is confusing with the first 2 dependecies.

roger4me commented 2 years ago

me too. so what should i do