简体   繁体   English

如何在cxf-xjc-plugin中禁用.xsd验证?

[英]How can I disable .xsd validation in cxf-xjc-plugin?

I'm trying to generate Java sources from XSD files form a provider (I cannot change those files) files with the maven cxf-xjc-plugin. 我正在尝试使用Maven cxf-xjc-plugin从提供程序(我无法更改那些文件)文件的XSD文件生成Java源代码。

Evertyhing was working fine, but I need to add a new .xsd file. Evertyhing工作正常,但是我需要添加一个新的.xsd文件。 This file includes other .xsd files inside and theres is a conflict because the new .xsd files defines entities with the same name as existing xsd files (I know, I know, but I am just a user of these .xsd files). 该文件内部包含其他.xsd文件,并且存在冲突,因为新的.xsd文件定义的实体与现有xsd文件具有相同的名称(我知道,但我只是这些.xsd文件的用户)。 Ah! 啊! they should be in the same package... 他们应该在同一个包装中...

The error is the typical: 该错误是典型的:

A schema cannot contain two global components with the same name; 模式不能包含两个具有相同名称的全局组件。 this schema contains two occurrences of ... 此架构包含两次...

I've read that someone was able to fix similar issues telling to the tool he was using to NOT validate the .xsd. 我读过有人可以解决类似的问题,告诉他使用的工具没有验证.xsd。

I was wondering if it is possible to tell to the cxf-xjc-plugin no to validate .xsd files and just convert into Java 我想知道是否可以告诉cxf-xjc-plugin否以验证.xsd文件并将其转换为Java

The maven configuration is as follows: Maven配置如下:

<plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-xjc-plugin</artifactId>
            <version>3.0.5</version>
            <configuration>
                <extensions>
                    <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.3.0</extension>
                </extensions>
            </configuration>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>

                        <forceRegenerate>false</forceRegenerate>

                        <sourceRoot>${project.basedir}/src/main/java</sourceRoot>                           
                        <xsdOptions>
                            <xsdOption>
                                <xsd>${basedir}/src/main/resources/webapi/xsd/SuperSchemaCommon.xsd</xsd>                                   
                                <packagename>com.XX.XXXXX.package</packagename>
                                <extensionArgs>
                                    <arg>-encoding</arg>
                                    <arg>UTF-8</arg>
                                </extensionArgs>
                            </xsdOption>
                            <xsdOption>
                                <xsd>${basedir}/src/main/resources/webapi/xsd/SuperSchemaInput.xsd</xsd>
                                <bindingFile>${basedir}/src/main/xjb/pnr/SuperSchemaInput.xjb</bindingFile>
                                <packagename>com.XXXXXXX.input</packagename>
                                <extensionArgs>
                                    <arg>-encoding</arg>
                                    <arg>UTF-8</arg>
                                </extensionArgs>
                            </xsdOption>

                        </xsdOptions>       
                    </configuration>                        
                    <goals>
                        <goal>xsdtojava</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Thanks in advance! 提前致谢!

Solution found! 找到解决方案!

Simply adding the xjc parameter "-nv" as another extension arg. 只需将xjc参数“ -nv”添加为另一个扩展名arg。 It is passed to the arguments of xjc when executing maven task 执行maven任务时,它将传递给xjc的参数

<xsdOption>
...
    <extensionArgs>
        <arg>-encoding</arg>
        <arg>UTF-8</arg>
        <arg>-nv</arg>
    </extensionArgs>
</xsdOption>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM