从另一个maven模块导入xsd时,JAXB无法生成类

时间:2017-06-18 08:03:37

标签: java xml maven xsd jaxb

我只是想知道也许你可以帮助我解决我的问题。 我有一个带有多个模块的Maven项目。 不幸的是,我无法从另一个模块导入(不能使用来自另一个xsd的类型)XSD。

我的项目结构如下:

我有两个模块,名称是用户管理一般手稿管理一般

用户管理常规包含名称为 user.management.bean.xsd 的XSD。我想将此XSD导入到 manuscript.management.bean.xsd 中,该 manuscript.management.bean.xsd 位于我的 manuscript-management-general 模块中。

我尝试了多种可能的解决方案而没有成功。

手稿 - 管理 - 通用模块的POM如下:

<properties>
    <user-management-general.version>0.0.1-SNAPSHOT</user-management-general.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.jvnet.jaxb2_commons</groupId>
        <artifactId>jaxb2-basics-runtime</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
    </dependency>
    <dependency>
        <groupId>manuscript.module.user.management</groupId>
        <artifactId>user-management-general</artifactId>
        <version>${user-management-general.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
        </plugin>
    </plugins>
</build>

jaxb2插件如下:

<pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>${maven-jaxb2-plugin.version}</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>${project.basedir}/src/generated</generateDirectory>
                            <extension>true</extension>
                            <removeOldOutput>true</removeOldOutput>
                            <useDependenciesAsEpisodes>true</useDependenciesAsEpisodes>
                            <scanDependenciesForBindings>true</scanDependenciesForBindings>
                            <args>
                                <arg>-XtoString</arg>
                                <!-- <arg>-no-header</arg> -->
                                <!-- <arg>-XReplacePrimitives</arg> -->
                                <arg>-XJsr303Annotations</arg>
                                <!-- <arg>-XJsr303Annotations:targetNamespace=a</arg> -->
                                <arg>-XhashCode</arg>
                                <!-- <arg>-Xequals</arg> -->
                                <arg>-Xsetters</arg>
                            </args>
                            <plugins>
                                <plugin>
                                    <groupId>com.github.krasa</groupId>
                                    <artifactId>krasa-jaxb-tools</artifactId>
                                    <version>${krasa-jaxb-tools.version}</version>
                                </plugin>
                                <plugin>
                                    <groupId>org.jvnet.jaxb2_commons</groupId>
                                    <artifactId>jaxb2-basics</artifactId>
                                    <version>${jaxb2-basics.version}</version>
                                </plugin>
                            </plugins>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>

user.management.bean.xsd是

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://manuscript/module/user/management/bean" 
    xmlns="http://manuscript/module/user/management/bean"
    elementFormDefault="qualified">

    <xsd:complexType name="academicDisciplines">
        <xsd:sequence>
            <xsd:element name="AcademicDisciplinesId" type="xsd:string" />
            <xsd:element name="AcademicDisciplinesName" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

我想在我的manuscript.management.bean.xsd中使用这个复杂类型作为类型。目前该文件如下:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://manuscript/module/manuscript/management/bean" 
xmlns="http://manuscript/module/manuscript/management/bean"
xmlns:usermanagement="http://manuscript/module/user/management/bean" 
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
elementFormDefault="qualified">

    <xsd:import namespace="http://manuscript/module/user/management/bean" schemaLocation="???"/>

    <xsd:complexType name="submission">
        <xsd:sequence>
            <xsd:element name="AcademicDisciplines" type="usermanagement:academicDisciplines" minOccurs="1" maxOccurs="unbounded" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:simpleType name="ROLE">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="AUTHOR_ROLE" />
            <xsd:enumeration value="REVIEWER_ROLE" />
            <xsd:enumeration value="EDITOR_ROLE" />
            <xsd:enumeration value="ADMIN_ROLE" />
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="basicResponse">
        <xsd:sequence>
            <xsd:element name="ExceptionMessage" type="xsd:string" />
            <xsd:element name="SuccessMessage" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

我尝试通过以下方式识别我的xsd,但它不起作用:

<xsd:import namespace="http://manuscript/module/user/management/bean" schemaLocation="maven:manuscript.module.user.management:user-management-general:jar::!/src/main/resources/user.management.bean.xsd" />

GitHub网址:

如果你能帮助我解决这个问题,我将非常感激。 抱歉我的英文:)

0 个答案:

没有答案