应用程序上下文中某些 Bean 的依赖关系形成一个循环
2022-09-01 16:53:31
我正在使用JPA开发Spring Boot v1.4.2.RELEASE应用程序。
我定义了存储库接口和实现
A存储库
@Repository
public interface ARepository extends CrudRepository<A, String>, ARepositoryCustom, JpaSpecificationExecutor<A> {
}
A存储库自定义
@Repository
public interface ARepositoryCustom {
Page<A> findA(findAForm form, Pageable pageable);
}
A存储库说明
@Repository
public class ARepositoryImpl implements ARepositoryCustom {
@Autowired
private ARepository aRepository;
@Override
public Page<A> 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 中描述的所有步骤
请帮忙!
劳伦