Answer the question
In order to leave comments, you need to log in
Mongodb not working in spring, how to fix??
ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringMongoConfig.class);
MongoOperations mongoOperation = (MongoOperations)ctx.getBean("mongoTemplate");
mongoOperation.save(new User("Name"));
@Configuration
public class SpringMongoConfig extends AbstractMongoConfiguration {
@Override
public String getDatabaseName() {
return "yourdb";
}
@Override
@Bean
public com.mongodb.Mongo mongo() throws Exception {
return new MongoClient("127.0.0.1");
}
}
HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
Answer the question
In order to leave comments, you need to log in
Judging by the error, your problem is using dependencies that are incompatible with each other. The specified method appeared in Spring Core version 4.2.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question