WELD-001408:使用 Spring Boot 3.1.1 和 Jboss Wildfly 27 时,带有限定符 @Default 的类型验证器的依赖关系不满足

问题描述 投票:0回答:1

在使用 Spirng boot 和 Jboss Wildfly 的应用程序中,当我将应用程序迁移到 Spring boot 3.1.1 和 wildfly 27 时,我出现此错误:

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Validator with qualifiers @Default
  at injection point [UnbackedAnnotatedField] @Inject private org.hibernate.validator.cdi.internal.interceptor.ValidationInterceptor.validator
  at org.hibernate.validator.cdi.internal.interceptor.ValidationInterceptor.validator(ValidationInterceptor.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:
  - ValidatorBean [id=org.hibernate.validator.cdi.internal.ValidatorBean_hv, qualifiers=[@org.hibernate.validator.cdi.HibernateValidator(), @jakarta.enterprise.inject.Any()]]
"}}

这个应用程序可以与 Spring boot 2.7 和 Jboss WildFly 15 配合使用。

有关可以提供帮助的更多信息,我将应用程序的 war 文件部署到 Wildfly 并排除嵌入式容器,并在尝试构建应用程序时导入 jakarta.servlet-api :

<dependency>
    <groupId>jakarta.servlet</groupId>
    <artifactId>jakarta.servlet-api</artifactId>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>

这个应用程序可以与嵌入式容器配合使用。

spring spring-boot wildfly bean-validation
1个回答
0
投票

在 Wildfly 上进行一些搜索和审查后,我明白我们需要使用 jboss-deployment-struct.xml 来排除 bean-validation 子系统。我也排除了 jsf 和焊接。 这是解决问题的 jboss-deployment-struct.xml :

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <deployment>
        <!-- Spring does not support CDI and therefore CDI required subsystem and dependencies must be excluded -->
        <exclude-subsystems>
            <subsystem name="jsf"/>
            <subsystem name="microprofile-opentracing-smallrye"/>
            <subsystem name="weld"/>
            <subsystem name="logging"/>
        </exclude-subsystems>
        <exclusions>
            <module name="org.jboss.resteasy.resteasy-cdi"/>
        </exclusions>
    </deployment>
</jboss-deployment-structure>
© www.soinside.com 2019 - 2024. All rights reserved.