You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Java11+SpringBoot2.1.6遇ValidationEventHandler错误求助

Hey there! Let's figure out why you're hitting that javax/xml/bind/ValidationEventHandler error with Java 11 and Spring Boot 2.1.6. I've run into similar issues before, so here's what to check and fix:

1. The Most Likely Culprit: jOOQ CodeGen Needs JAXB in Buildscript Classpath

You mentioned adding JAXB dependencies to your application's compile classpath, but your jOOQ libraries (jooq, jooq-meta, jooq-codegen) are in the buildscript classpath. The jOOQ code generation task runs using the buildscript's classpath, not your app's runtime dependencies—so it can't see the JAXB jars you added for the app.

Fix this by adding JAXB dependencies to your buildscript block too:

buildscript {
    dependencies {
        classpath group: 'org.jooq', name: 'jooq', version: '3.10.7'
        classpath group: 'org.jooq', name: 'jooq-meta', version: '3.10.7'
        classpath group: 'org.jooq', name: 'jooq-codegen', version: '3.10.7'
        // Add these JAXB dependencies for codegen
        classpath group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.2'
        classpath group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.2'
        classpath group: 'javax.activation', name: 'activation', version: '1.1.1'
    }
}

2. Simplify Dependencies with Spring Boot's JAXB Starter

Instead of manually adding all individual JAXB jars, use Spring Boot's curated starter to avoid version mismatches:

// Replace your manual JAXB compile dependencies with this
implementation 'org.springframework.boot:spring-boot-starter-jaxb'

This starter automatically pulls in all the necessary JAXB components compatible with Spring Boot 2.1.6 and Java 11.

3. Upgrade jOOQ for Better Java 11 Support

jOOQ 3.10.7 is a relatively old version (released in 2018) and has limited support for Java 11. Java 11 removed JAXB from the JDK, and newer jOOQ versions (3.12+) are explicitly built to handle this change. Upgrading to a Java 11-compatible jOOQ version will reduce compatibility headaches long-term.

4. Verify Dependencies Are Not Excluded

Run ./gradlew dependencies to generate a dependency tree. Check that none of the JAXB-related dependencies are being excluded accidentally by other plugins or dependencies. If you see exclusions, you may need to adjust your build config to retain them.

内容的提问来源于stack exchange,提问作者Rubert

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 22:29:08