gpt4 book ai didi

java - 焊接-001408 : Unsatisfied dependencies for repositories from Spring Data

转载 作者:太空宇宙 更新时间:2023-11-04 11:50:49 26 4
gpt4 key购买 nike

我当前的工作是将我的 Java EE 应用程序从 Jboss 7 服务器迁移到 Wildfly 10。我在集成 CDI 和 Spring-Data 时遇到问题。我使用与 Jboss 7 相同的配置。当我尝试将应用程序部署到 Wildfly 服务器时,我收到与将 spring 数据存储库注入(inject)某些 CDI 和 EJB beans 相关的错误。

错误看起来像这样:

 org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type StudentExtTrainingRepository with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private pl.mynetwork.mylearning.logic.historyTraining.HistoryTrainingService.studentExtTrainingRepository
at pl.mynetwork.mylearning.logic.historyTraining.HistoryTrainingService.studentExtTrainingRepository(HistoryTrainingService.java:0)

at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)

我根据 spring data 配置指南配置了我的应用程序,我在这里找到了 https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpd.misc.cdi-integration但在野蝇上它不起作用。

我有这样的实体管理器生产者类

@Dependent
public class SpringDataConfigurationProducer {


@Produces
@ApplicationScoped
public EntityManagerFactory createEntityManagerFactory() {
return Persistence.createEntityManagerFactory("base-pu");
}

@Produces
@RequestScoped
public EntityManager createEntityManager(EntityManagerFactory entityManagerFactory) {
return entityManagerFactory.createEntityManager();
}
}

当然,我的项目中的 META-INF 目录下有文件 beans.xml。

存储库,我尝试注入(inject)的内容如下所示:

@Repository
@Transactional
@Dependent
public interface StudentExtTrainingRepository extends JpaRepository<StudentExtTraining, Long> {
}

我想要注入(inject)存储库的服务看起来:

@Service
public class HistoryTrainingService {

@Inject
private StudentExtTrainingRepository studentExtTrainingRepository;
}

我有单独的 Spring 数据存储库项目和单独的服务/EJB 项目。两者都打包到一个 EAR 中。有人有什么建议吗?我花了很多时间解决这个问题,但找不到解决方案。

最佳答案

也添加这个类。

class CdiConfig {    
@Produces
@RequestScoped
@PersistenceContext
public EntityManager entityManager;
}

关于java - 焊接-001408 : Unsatisfied dependencies for repositories from Spring Data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41853463/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com