cxf-codegen-plugin 4.0.0 忽略绑定文件

use*_*252 6 wsdl2java cxf-codegen-plugin

我从基于cxf-codegen-plugin. 我使用额外的绑定

  • 更改包
  • 使用Date而不是XmlGregorianCalender

这适用于版本 3.5.5

当我切换到 4.0.0 时,这不再起作用(默认包并被XmlGregorianCalender使用)。我在迁移指南中找不到任何相关内容。

这是我的配置

pom.xml

<plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>4.0.0</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>https:url?wsdl</wsdl>
                                    <bindingFiles>
                                        <bindingFile>${basedir}/src/main/resources/bindings.xml</bindingFile>
                                    </bindingFiles>
                                    <extraargs>
                                        <extraarg>-verbose</extraarg>
                                        <extraarg>-p</extraarg>
                                        <extraarg>http://url/service=com.some.package</extraarg>
                                        <extraarg>-xjc-Xts:style:org.apache.commons.lang3.builder.ToStringStyle.DEFAULT_STYLE</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.cxf.xjcplugins</groupId>
                        <artifactId>cxf-xjc-ts</artifactId>
                        <version>4.0.0</version>
                    </dependency>
                </dependencies>
            </plugin>
Run Code Online (Sandbox Code Playgroud)

绑定

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<jaxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:jaxws="http://cxf.apache.org/jaxws"
               version="2.1">

    <jaxb:bindings schemaLocation="https://url.file.xsd"
                   node="/xsd:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="com.some.package.dto" />
        </jaxb:schemaBindings>
        <jaxb:globalBindings>
            <jaxb:javaType name="java.util.Date"
                           xmlType="xsd:dateTime"
                           parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDateTime"
                           printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDateTime" />
            <jaxb:javaType name="java.util.Date"
                           xmlType="xsd:date"
                           parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDate"
                           printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDate"/>
            <jaxb:javaType name="java.util.Date"
                           xmlType="xsd:time"
                           parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseTime"
                           printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printTime"/>
        </jaxb:globalBindings>
    </jaxb:bindings>

</jaxb:bindings>
Run Code Online (Sandbox Code Playgroud)

小智 12

我在 4.0.0 版本中也遇到了同样的问题。好像都是javax. * 规格已替换为jakarta。* 眼镜。

所以我意识到我必须将绑定文件中的xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"和替换xmlns:jaxws="http://cxf.apache.org/jaxws"为 jakarta 的:

<jaxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
               xmlns:jaxws="https://jakarta.ee/xml/ns/jaxws"
               version="3.0">

....

</jaxb:bindings>
Run Code Online (Sandbox Code Playgroud)

据我所知,官方 apache cxf 文档没有明确提及这一点。但您可以在此处检查 Jakarta XML Web Services WSDL 自定义描述符的 XML 架构。

  • 谢谢你!我已经研究了好几天了,终于找到了你的答案! (2认同)

小智 0

不幸的是,4.0.0 插件似乎有问题。我遇到了同样的问题 - 绑定文件被忽略。

我已经使用单个设置对其进行了测试: <jaxb:globalBindings typesafeEnumMaxMembers="2000"/>

并且总是得到相同的结果:[警告]警告:文件:/C:/skr/src/main/resources/Service/language.xsd [3,3]:由于EnumMemberSizeCap,简单类型“LanguageCodeEnum”未映射到Enum限制。Facet 计数:501,当前限制:256。您可以使用自定义属性“typesafeEnumMaxMembers”来扩展限制。

因此该源被忽略并且不会生成工件。

相同的绑定文件适用于以前的(3.5.5)版本的插件。