Mongo db - Property' mongoOperations'扔了例外

时间:2016-06-23 16:46:26

标签: java spring mongodb

我尝试使用spring-data-mongodb 1.2.0.RELEASE和spring 3.1.3.RELEASE就像你的情况一样,但是我收到一个错误:

PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'mongoOperations' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean.setMappingContext(Lorg/springframework/data/mapping/context/MappingContext;)V

当我从Repository扩展我的存储库时会发生这种情况:

public interface JsonDataRepository extends Repository<JsonData, String> {  
    List<JsonData> findBySourceTableAndSourceId(String sourceTable, Long sourceId);
}

我的xml配置等于您的帖子。请告诉我在我的存储库中是否缺少注释?????

1 个答案:

答案 0 :(得分:0)

您是否可以MongoRepository代替Repository

import org.springframework.data.mongodb.repository.MongoRepository;

public interface JsonDataRepository extends MongoRepository<JsonData, String> {  
    List<JsonData> findBySourceTableAndSourceId(String sourceTable, Long sourceId);
}