我正在使用JPA开发Spring Boot v1.4.2.RELEASE应用程序.
我定义了存储库接口和实现
ARepository
@Repository public interface ARepository extends CrudRepository, ARepositoryCustom, JpaSpecificationExecutor { }
ARepositoryCustom
@Repository public interface ARepositoryCustom { Page findA(findAForm form, Pageable pageable); }
ARepositoryImpl
@Repository public class ARepositoryImpl implements ARepositoryCustom { @Autowired private ARepository aRepository; @Override public Page findA(findAForm form, Pageable pageable) { return aRepository.findAll( where(ASpecs.codeLike(form.getCode())) .and(ASpecs.labelLike(form.getLabel())) .and(ASpecs.isActive()), pageable); } }
和服务 AServiceImpl
@Service public class AServiceImpl implements AService { private ARepository aRepository; public AServiceImpl(ARepository aRepository) { super(); this.aRepository = aRepository; } ... }
我的应用程序不会以消息开头:
*************************** APPLICATION FAILED TO START *************************** Description: The dependencies of some of the beans in the application context form a cycle: | aRepositoryImpl ???????
我按照http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.single-repository-behaviour中描述的所有步骤进行了操作
请帮忙 !
洛朗
对原始问题有一个简单的解决方法:只需从ARepositoryCustom和ARepositoryImpl中删除@Repository即可.保留所有命名和接口/类层次结构.一切都好.