无法找到或加载主 class com.sun.tools.internal.xjc.Driver

Could not find or load main class com.sun.tools.internal.xjc.Driver

我想使用 IntelliJ 工具并使用 JAXB 从 XML 模式生成 Java 代码,但我遇到了上述错误问题。

JAXB tool window

这是我的 .xsd 文件,我想从中生成代码:

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://localhost:9090/api/productions/list"
           targetNamespace="http://localhost:9090/api/productions/list"
>

    <xs:element name="getProduction">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="id" type="xs:long"/>

            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="getResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="production" type="tns:production"/>

            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:complexType name="production">
        <xs:sequence>
            <xs:element name="id" type="xs:long"/>
            <xs:element name="guid" type="xs:string"/>
            <xs:element name="name" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

</xs:schema>

有人知道问题出在哪里吗?

恐怕 运行 JDK 版本 9 及更高版本不支持来自 IntelliJ IDEA 的 jxc。请参阅 IDEA-179691 和相关问题以获取更多信息。

“使用 JAXB 从 Java 生成 Xml 架构”操作应与 Java 8.

一起使用