2013-06-17 3 views
1

에 대한가 아닌 경우 관리되는 형식 I 다음 몽고 구성이 있습니다봄 데이터 MongoDB를

<context:component-scan base-package="com.example" /> 
<mongo:repositories base-package="com.example.repositories.mongodb" /> 

다음과 같이 내가 저장소를 가지고 :

package com.example.repositories.mongodb; 
public interface ReviewRepository extends CrudRepository<Review, String> {...} 

와 콩 :

package com.example.domain; 
@Document(collection="Review") 
public class Review implements Serializable { ... } 

을 불행히도 앱을 시작하면 다음 예외가 발생합니다.

에 의해 발생 : org.springframework.beans.factory.BeanCreationException : 필드 autowire하기 수 없습니다 : 개인 com.example.repositories.mongodb.ReviewRepository com.example.Controller.reviewRepository을; 중첩 예외는 입니다. org.springframework.beans.factory.BeanCreationException : 오류 'reviewRepository'라는 이름으로 bean을 생성합니다. FactoryBean은 객체 생성시 예외를 발생 시켰습니다. 가 아닌 경우 관리되는 형식 : 클래스 com.example.domain.Review

....

에 의해 발생 : java.lang.IllegalArgumentException가 : 중첩 된 예외는 java.lang.IllegalArgumentException가 아니다 관리되는 형식 : 클래스

내가이이 저장소에 의해 발생 될 수 있다고 생각 com.example.domain.Review하고 같은 패키지에없는 관리하는 콩. 하지만 같은 패키지에 넣을 때도 같은 문제가 발생합니다. 어떤 아이디어?

+0

이는 일반적으로 지속성 계층이 일부 클래스 (이 경우 검토 - 검토)를 인식하지 못한다는 것을 의미합니다. 당신은 mongo를 가지고 있습니까 : 저장소와 컨텍스트 : 같은 맥락에서 컴포넌트 스캔을 설정합니까? – pl47ypus

+0

예. 구성 요소를 동일한 컨텍스트에서 검색했습니다. 다른 아이디어? 감사. – checklist

+0

불행히도, 같은 맥락에서 벗어난 것을 제외하고는, 마음에 떠오르는 유일한 다른 일은 @Document 주석이 옳지 않다는 것입니다. 더 많은 코드가 필요해. – pl47ypus

답변

0

동일한 프로젝트에서 우리는 mysql을 사용하고 있으며 패키지를 검색하고 있습니다 : com.example.repositories. 이로 인해 문제가 발생했으며 일단 com.example.repositories.mysql로 ​​변경하면 문제가 해결되었습니다.

관련 문제