简体   繁体   English

在SpringMVC应用中初始化MongoDB存储库时出错

[英]Error initialising MongoDB repository in SpringMVC app

I'm trying to set up a basic Spring MVC app with MongoDB intergration. 我正在尝试通过MongoDB集成来设置基本的Spring MVC应用程序。 Using Java 7 JDK 使用Java 7 JDK

However when trying to build the project with Maven I am seeing a compilation error as follows: 但是,当尝试使用Maven生成项目时,出现如下编译错误:

[ERROR] \workspace\apache-analyser\src\main\java\com\apache\analyser\repository\RequestRepository.java:[7,7] 
error: name clash: <S>save(Iterable<S>) in CrudRepository and save(Iterable<? extends T#2>) in MongoRepository have the same erasure, yet neither overrides the other 

Here is the Repository interface: 这是存储库接口:

package com.apache.analyser.repository;

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

import com.apache.analyser.domain.Request;

public interface RequestRepository extends MongoRepository<Request, String> {

}

And the Spring configuration to initialise this: 然后使用Spring配置对此进行初始化:

<mongo:repositories base-package="com.apache.analyser.repository" />

It seems like a basic setup I am trying to do so not sure why I am seeing this error. 似乎是我尝试执行的基本设置,所以不确定为什么我会看到此错误。 Has anyone seen this or is aware of why this might happen? 有没有人看到或知道为什么会发生这种情况?

I solved my problem by changing spring-data-commons-core version from 1.3.1 to 1.2.1. 我通过将spring-data-commons-core版本从1.3.1更改为1.2.1解决了我的问题。 This last one is used with spring-data-mongodb 1.0.3. 最后一个与spring-data-mongodb 1.0.3一起使用。

I have solved my issue by reverting to Java 6 JDK. 我已经恢复到Java 6 JDK解决了我的问题。 I am not sure why this is not working with Java7 so if anyone is aware It'd be great to hear! 我不确定为什么它不能与Java7一起使用,所以如果有人知道的话,那真是太好了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM