有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java更改生成的jaxb类的类名和包结构

请求架构-

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.G9.Request.com" xmlns:tns="http://www.G9.Request.com">
<xsd:complexType abstract="false" block="#all" final="#all" mixed="false" name="ProgramInterface">

响应模式-

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.G9.Response.com" xmlns:tns="http://www.G9.Response.com">
<xsd:complexType abstract="false" block="#all" final="#all" mixed="false" name="ProgramInterface">

我正在使用maven-jaxb2-plugin插件生成jaxb类。我希望在目标目录中的com.wsdl包中生成ProgramInterfaceInput作为我的请求类和ProgramInterfaceReponse作为我的响应类

下面是我的POM和绑定。xjb目录-

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.1</version>
                <executions>
                    <execution>
                        <id>G9-schema-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                              <schemas>
                                 <schema>
                                     <url>http://abc.xyzcorp.com:10000/ABC/G9?wsdl</url>
                                 </schema>
                             </schemas>
                            <bindingFiles>
                                <bindingFile>${basedir}/src/main/resources/bindings.xjb</bindingFile>
                            </bindingFiles>
                           <generateDirectory>${project.build.directory}/generated-sources/xjc2</generateDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

绑定。xjb

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

    <jaxws:bindings wsdlLocation="http://abc.xyzcorp.com:10000/ABC/G9?wsdl">
        <jaxws:bindings
                node="//xsd:schema[@targetNamespace='http://www.G9.Request.com']/xsd:complexType[@name='ProgramInterface']">
            <jxb:schemaBindings>
                <jxb:package name="com.wsdl"/>
                <jxb:nameXmlTransform>
                    <jxb:typeName suffix="Request"/>
                </jxb:nameXmlTransform>
            </jxb:schemaBindings>
        </jaxws:bindings>
        <jaxws:bindings
                node="//xsd:schema[@targetNamespace='http://www.G9.Response.com']/xsd:complexType[@name='ProgramInterface']">
            <jxb:schemaBindings>
                <jxb:package name="com.wsdl"/>
                <jxb:nameXmlTransform>
                    <jxb:typeName suffix="Response"/>
                </jxb:nameXmlTransform>
            </jxb:schemaBindings>
        </jaxws:bindings>
    </jaxws:bindings>

这并没有给我想要的结果。它最终创建了两个包作为-

com.request.g9 - ProgramInterface.java
com.response.g9 - ProgramInterface.java

我想要的是-

com.wsdl - ProgramInterfaceRequest.java & ProgramInterfaceResponse.java

请给我一些建议


共 (0) 个答案