焊接 (CDI) + JPA

WELD (CDI) + JPA

我尝试 运行 我在此处找到的示例: Using CDI/Weld to Inject JPA/Hibernate Entity Managers

我收到错误:

WELD-001408:Unsatisfied dependencies for type EntityDao<User> with qualifiers @Named at injection point [BackedAnnotatedField] @Inject @Named private com.payby.user.UserIdentityDao.baseEntityDao

我还尝试 运行 来自以下示例的示例: https://bpm.zciok.blog/2017/08/17/hibernate-cdi-example/

但我得到了同样的错误。任何人都可以帮助我理解为什么以及如何解决它。

谢谢, 艾夫纳

对于 https://bpm.zciok.blog/2017/08/17/hibernate-cdi-example/,请在 pom.xml 中进行以下更改,请

添加持久化-api依赖

   <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
            <version>2.2</version>
        </dependency>

从对休眠的依赖中删除scope:provided

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${version.hibernate}</version>
        <!--<scope>provided</scope>-->
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.1.1.Final</version>
        <!--<scope>provided</scope>-->
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${version.hibernate}</version>
        <!--<scope>provided</scope>-->
    </dependency>