Tor*_*ora 5 deployment spring-boot jboss-eap-7
我正在尝试在 JBoss EAP 7.1 服务器上部署 Spring Boot (2.0.2) 应用程序。
导致问题的代码是:
import javax.validation.constraints.NotBlank;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
@Component
@Validated
public class AppProperties {
@NotBlank
private String name;
Run Code Online (Sandbox Code Playgroud)
当应用程序部署在 JBoss 上时,我收到以下异常:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
16:44:25,861 ERROR [org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter] (ServerService Thread Pool -- 6 7)
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'app' to com.example.security.config.AppProperties:
Property: app.contextpath
Value: /api
Origin: class path resource [application.yml]:5:18
Reason: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.String'. Check configuration for 'name'
Action:
Update your application's configuration
Run Code Online (Sandbox Code Playgroud)
我已经尝试将包含以下内容的文件 jboss-deployment-structure.xml 添加到 WEB-INF/classes:
<jboss-deployment-structure>
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs"/>
</exclude-subsystems>
<exclusions>
<module name="javaee.api"/>
<module name="javax.validation.api"/>
<module name="javax.faces.api"/>
<module name="org.hibernate.validator"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
Run Code Online (Sandbox Code Playgroud)
但是,没有运气。解决方法是什么?提前致谢。
尽管这个问题已经有一年了,但我遇到了同样的问题并且找不到解决方案。
我知道,这适用于 Spring Boot 2.1.x 和 JBoss 7.1,不确定之前的版本。
我们显然需要排除org.hibernate.validator和javax.validation.api。不清楚的是,我们还需要排除javax.faces.api(它对 有传递依赖javax.validation.api)。由于缺少 jsf 库,排除 javax.faces 会导致 JBoss 在启动时失败。然后我们可以简单地排除jsf子系统。
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="jsf" />
</exclude-subsystems>
<exclusions>
<module name="javax.validation.api" />
<module name="javax.faces.api" />
<module name="org.hibernate.validator" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Run Code Online (Sandbox Code Playgroud)
假设您不需要 jboss 的 JSF,这应该可以工作。
| 归档时间: |
|
| 查看次数: |
2048 次 |
| 最近记录: |