我试图让 Spring 数据 JPA 与 EJB 和 CDI (Java EE 7) 一起使用。好吧,我按照文档(http://docs.spring.io/spring-data/jpa/docs/1.4.2.RELEASE/reference/html/jpa.repositories.html#jpd.misc.cdi-integration),但仍然无法在无状态 ejb 中 @inject 我的存储库。以下是代码:
@Configuration
@EnableJpaRepositories
public class EntityManagerFactoryProducer {
@Produces
@ApplicationScoped
public EntityManagerFactory entityManagerFactory() {
return Persistence.createEntityManagerFactory("mypu");
}
public void close(@Disposes EntityManagerFactory entityManagerFactory) {
entityManagerFactory.close();
}
}
$
public interface TipoFolhaRepository extends JpaRepository<TipoFolha, Long> {
List<TipoFolha> findByNome(String nome);
TipoFolha findByTipo(String tipo);
}
$
@Stateless
public class TipoFolhaFacade extends AbstractFacade<TipoFolha> {
@Inject
TipoFolhaRepository tpRepo;
@Override
public List<TipoFolha> findAll(){
return tpRepo.findAll();
}
}
跟随错误。WELD-001408 在注入点 [[BackedAnnotatedField] @Inject com.mycompany.ejb.TipoFolhaFacade.tpRepo] 具有限定符 [@Default] 的类型 [TipoFolhaRepository] 的依赖关系不满足
我错过了什么?=S