标签: maven-jaxb2-plugin

如何在maven-jaxb2-plugin中指定JAXB版本?

我需要使用最新版本jaxb:2.2.4-1,但maven或maven-jaxb2-plugin似乎从JDK中获取了一个.

我尝试指定这样的版本:

<configuration>
    <specVersion>2.2</specVersion>
    ...
</configuration>
Run Code Online (Sandbox Code Playgroud)

但是日志显示:

[INFO] [jaxb2:generate {execution: common}]
[INFO] Started execution.
[INFO] JAXB API is loaded from the [jar:file:/opt/jdk1.6.0_24/jre/lib/rt.jar!].
[INFO] Detected JAXB API version [2.1].
Run Code Online (Sandbox Code Playgroud)

我试图将依赖项添加到正确版本的javax.xml.bind:jaxb-api和com.sun.xml.bind:jaxb-impl,但这没有帮助.

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

        <dependencies>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.2.4</version>
            </dependency>

            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>2.2.4-1</version>
            </dependency>
        </dependencies>

        <executions>
            <execution>
                <id>common</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <specVersion>2.2</specVersion>
                    ...
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)

我也尝试过使用maven-jaxb22-plugin但它也没用.

maven-2 jaxb2 maven maven-jaxb2-plugin

5
推荐指数
1
解决办法
9384
查看次数

如何让xven-jaxws-plugin在xsd生成的类上生成@XmlElementWrapper?

我正在使用maven-jaxws-plugin从我的wsdl,schema中生成java类.它不会在生成的类中生成@XmlElementWrapper注释.从这篇文章我明白我需要使用jaxb-xew-plugin但是我无法使用maven-jaxws-plugin.任何帮助,将不胜感激.这是我试过的配置

<plugin>
    <groupId>org.jvnet.jax-ws-commons</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>2.2</version>
    <executions>
    <execution>
        <goals>
                <goal>wsimport</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
                <xjcArgs>
                    <xjcArg>-no-header</xjcArg>
                    <xjcArg>-Xxew</xjcArg>
                    <xjcArg>-Xxew:instantiate lazy</xjcArg>
                    <xjcArg>-Xxew:delete</xjcArg>
                </xjcArgs>
                <extension>true</extension>

                <wsdlDirectory>${basedir}/src/main/resources</wsdlDirectory>
                <wsdlFiles>
                    <wsdlFile>attribute-service.wsdl</wsdlFile>
                </wsdlFiles>
                <sourceDestDir>${project.build.directory}/generated</sourceDestDir>
                <verbose>true</verbose>
                <keep>true</keep>
                <plugins>
                    <plugin>
                        <groupId>com.github.jaxb-xew-plugin</groupId>
                        <artifactId>jaxb-xew-plugin</artifactId>
                        <version>1.0</version>
                    </plugin>
                </plugins>
            </configuration>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

如果它只能与maven-jaxb2-plugin集成,你可以帮我搞网络服务吗?基本上如何指定wsdl以及如何生成Service类?(使用@WebService注释)

谢谢,

Bhagya

wsimport maven-jaxb2-plugin jax-ws-customization jaxb-xew-plugin

5
推荐指数
1
解决办法
9263
查看次数

XPath评估结果为空目标节点

我正在尝试使用WSDL并使用maven-jaxb2-plugin生成绑定类.

WSDL是这样的,

<wsdl:definitions>
  <wsdl:types>
  ...
  </wsdl:types>
  ...
  <wsdl:message name="IServiceWeb_GetPaymentInfo_InputMessage">
    <wsdl:part name="parameters" element="tns:GetPaymentInfo"/>
  </wsdl:message>
  ...
  <wsdl:portType name="IServiceWeb">
      ...
      <wsdl:operation name="GetPaymentInfo">
         <wsdl:input wsaw:Action="*****" message="tns:IServiceWeb_GetPaymentInfo_InputMessage"/>
         <wsdl:output wsaw:Action="*****" message="tns:IServiceWeb_GetPaymentInfo_OutputMessage"/>
       </wsdl:operation>
  </wsdl:portType>
Run Code Online (Sandbox Code Playgroud)

当我最初尝试生成类时,我收到此错误,

org.xml.sax.SAXParseException: A class/interface with the same name "org.package.GetPaymentInfoResponse" is already in use. Use a class customization to resolve this conflict.
Run Code Online (Sandbox Code Playgroud)

我在这个内容中添加了binding.xjb文件,

<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
    xsi:schemaLocation=" http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" version="2.1">
    <bindings
        node="wsdl:definitions/wsdl:message[@name='IServiceWeb_GetPaymentInfo_OutputMessage']/wsdl:part[@name='parameters']">
        <class name="GetPaymentInfoOutputMessage" />
    </bindings>
</bindings>
Run Code Online (Sandbox Code Playgroud)

而我得到的错误是,

com.sun.istack.SAXParseException2: XPath evaluation of "wsdl:definitions/wsdl:message[@name='IServiceWeb_GetPaymentInfo_OutputMessage']/wsdl:part[@name='parameters']" results in empty target node
Run Code Online (Sandbox Code Playgroud)

是否有任何建议来生成这些文件?

编辑 …

xpath maven-jaxb2-plugin

5
推荐指数
1
解决办法
8487
查看次数

maven-jaxb2-plugin不同包中的多个模式错误

我有问题maven-jaxb2-plugin.我想要实现的是从x个不同的wsdl生成源到不同的包.

我想避免使用多个方法,<execution>所以当我添加另一个wsdl时,我可以保持pom.xml不变.

我配置了像这样的maven插件:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.12.1</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <schemaDirectory>src/main/resources/webservice/wsdl</schemaDirectory>
                    <schemaIncludes>
                        <include>orig/*.wsdl</include>
                    </schemaIncludes>

                    <bindingDirectory>src/main/resources/webservice/xjb</bindingDirectory>
                    <bindingIncludes>
                        <include>orig/*.xjb</include>
                    </bindingIncludes>
            </configuration>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

在我的理解中,这种方式我指定了.wsdl位置以及绑定文件位置.

现在在一个示例绑定文件中(所有这些都以相同的方式构造)我得到以下代码:

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
    jaxb:version="2.1">


    <jaxb:bindings schemaLocation="../../wsdl/orig/soap1.wsdl"
        node="*/xs:schema">

        <jaxb:schemaBindings>
            <jaxb:package name="my.package.com.soap1" />
        </jaxb:schemaBindings>
    </jaxb:bindings>

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

另一项服务是soap2,soap3等,它们都有类似的绑定文件.如果我理解这是正确的,多亏了这个connfig我应该能够在单独的包中为我的肥皂生成域对象.

但是当我运行时,maven clean compile我得到以下输出:

[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/me/workspace/orig-project/src/main/resources/webservice/wsdl/orig/soap1.wsdl{202,39}].
org.xml.sax.SAXParseException; systemId: file:/C:/Users/me/workspace/orig-project/src/main/resources/webservice/wsdl/orig/soap1.wsdl; lineNumber: 202; columnNumber: 39; 'Line' **is already defined**
Run Code Online (Sandbox Code Playgroud)

更重要的是,出于测试目的,我尝试配置插件来单独处理每个wsdl <execution>(我想在最终代码中避免这种情况),我观察到的是在第一个ex之后.处理了soap1.wsdl,正确创建了包,但根本没有创建其他soap.wsdl的包.(只有第一次处理). …

java soap wsdl xjc maven-jaxb2-plugin

5
推荐指数
0
解决办法
1922
查看次数

源代码生成过程中出现错误:“不是此编译的一部分。这是一个错误吗”

我有 jenkins 构建机器,源安装在 SSD 驱动器上。在编译和源代码生成期间,我收到以下错误:

[错误] 文件:/mnt/raid0/var/lib/jenkins/workspace/VIS_Constructor/vis-web/src/main/webapp/concentrator/binding.xml[13,53] com.sun.istack.SAXParseException2; systemId:文件:/mnt/raid0/var/lib/jenkins/workspace/VIS_Constructor/vis-web/src/main/webapp/concentrator/binding.xml; 行号:13;列数:53;“file:/mnt/raid0/var/lib/jenkins/workspace/VIS_Constructor/vis-web/src/main/webapp/concentrator/concentratorSub.xsd”不是这个编译的一部分。这是“文件:/var/lib/jenkins/workspace/VIS_Constructor/vis-web/src/main/webapp/concentrator/concentratorSub.xsd”的错误吗?

binding.xml 和 xsd 文件在同一目录中。

这是 binding.xml 的片段

<jxb:bindings schemaLocation="concentratorSub.xsd">
    <jxb:schemaBindings>
        <jxb:package name="com.ats.vis.services.concentrator" />
    </jxb:schemaBindings>
</jxb:bindings>
Run Code Online (Sandbox Code Playgroud)

我已经没有办法解决这个问题了。

任何帮助都将得到认可。谢谢。

java xsd jaxb maven maven-jaxb2-plugin

5
推荐指数
0
解决办法
3683
查看次数

使用 maven-jaxb2-plugin 从多个 wsdl 文件生成类

我可以从一个 wsdl 文件生成类,如下所示:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.12.3</version>
    <configuration>
        <schemaLanguage>WSDL</schemaLanguage>
        <schemaDirectory>src/main/resources</schemaDirectory>
        <schemaIncludes>
            <include>bwl_1_1.wsdl</include>
        </schemaIncludes>
        <generatePackage>bwl.wsdl</generatePackage>
        <generateDirectory>${project.build.directory}/generated-sources/bwl</generateDirectory>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

当我尝试使用 multiple 时<plugin>,只生成其中之一。我发现如果我想从多个文件生成类,我应该使用<executions>. 但是,当我包装<configuration>到时<executions>,它不再生成,实际上它从目录中的 xsd 文件生成一些内容...

我的无效尝试:

    <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.12.3</version>

        <executions>
            <execution>
                <id>bwl</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <schemaDirectory>src/main/resources</schemaDirectory>
                    <schemaIncludes>
                        <include>bwl_1_1.wsdl</include>
                    </schemaIncludes>
                    <generatePackage>bwl.wsdl</generatePackage>
                    <generateDirectory>${project.build.directory}/generated-sources/bwl</generateDirectory>
                </configuration>
            </execution>

            <execution>
                <id>score</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <schemaDirectory>src/main/resources</schemaDirectory>
                    <schemaIncludes>
                        <include>score_1_1.wsdl</include>
                    </schemaIncludes>
                    <generatePackage>score.wsdl</generatePackage>
                    <generateDirectory>${project.build.directory}/generated-sources/score</generateDirectory>
                </configuration>
            </execution>
        </executions>

    </plugin>
Run Code Online (Sandbox Code Playgroud)

谢谢。

wsdl jaxb2 maven maven-jaxb2-plugin

5
推荐指数
1
解决办法
1万
查看次数

Gradle 中的 Maven jaxb2 插件

我需要将 Maven 项目迁移到 gradle。maven 项目使用的maven-jaxb2-plugin是这样的(插件的版本设置在 root 中pom.xml):

<plugin>
  <groupId>...</groupId>
  <artifactId>maven-jaxb2-plugin</artifactId>
  <executions>
    <execution>
      <goals>
        <goal>generate</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <generatePackage>package for generated classes</generatePackage>
    <schemaDirectory>directory containing XSD files</schemaDirectory>
    <includeSchemas>
        <includeSchema>XSD file name</includeSchema>
        <includeSchema>XSD file name</includeSchema>
        ...
    </includeSchemas>
    <strict>true</strict>
    <verbose>true</verbose>
    <extension>true</extension>
  </configuration>
<plugin>
Run Code Online (Sandbox Code Playgroud)

所以,我想在 gradle 中实现相同的功能,这就是我所拥有的:

plugins {
  id "com.github.jacobono.jaxb" version "1.3.5"
}
dependencies {
  jaxb "org.glassfish.jaxb:jaxb-runtime:2.2.11"
  jaxb "org.glassfish.jaxb:jaxb-xjc:2.2.11"
}
jaxb {
  xsdDir = "directory containing XSD files"
  xjc {
    taskClassname = "com.sun.tools.xjc.XJC2Task"
    generatedPackage = "package for generated classes" …
Run Code Online (Sandbox Code Playgroud)

gradle maven maven-jaxb2-plugin

5
推荐指数
1
解决办法
7472
查看次数

maven-jaxb2-plugin失败,JAXB版本属性必须存在

我有以下配置maven-jaxb2-plugin:

            <!-- https://mvnrepository.com/artifact/org.jvnet.jaxb2.maven2/maven-jaxb2-plugin -->
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <strict>false</strict>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <generatePackage>com.mycompany.project.domain.wsdl</generatePackage>
                    <schemas>
                        <schema>
                            <url>url or file</url>
                        </schema>
                    </schemas>
                </configuration>
            </plugin>
Run Code Online (Sandbox Code Playgroud)

它失败了:

[ERROR] Error while parsing schema(s).Location [ file:/home/hasancansaral/workspace/company/domain/src/main/xsd/delivery.wsdl{2,366}].
Run Code Online (Sandbox Code Playgroud)

org.xml.sax.SAXParseException; systemId:file:/home/hasancansaral/workspace/company/domain/src/main/xsd/delivery.wsdl; lineNumber:2; columnNumber:366; 必须存在JAXB版本属性

如果我通过IntelliJ IDEA运行插件或做一个简单的操作,它没有什么区别mvn clean jax2b:generate.但是,使用可在此处找到的架构的操作是成功的,因此我怀疑我的wsdl架构实际上是格式错误的,我暂时无法公开,但可以通过消息提供(我知道它没有多大帮助按原样公开,但如果问题出现在模式中,我将在此处发布相关的问题部分).

注意: SOAP UI也会验证架构.

注2: 同样的错误是存在既jax2b-maven-pluginmaven-jax2b-plugin.

jaxb maven-plugin maven maven-jaxb2-plugin jaxb2-maven-plugin

5
推荐指数
1
解决办法
2531
查看次数

java.lang.NoClassDefFoundError 与包信息

我在 Windows 上使用 Maven 将我的项目构建为一个可执行 jar,并且我想在 Linux 上运行我的 jar 文件。

我收到此错误:

18:43:15.482 [http-nio-8080-exec-7] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: BOOT-INF/classes/OPS/package-info (wrong name: OPS/package-info)] with root cause
java.lang.NoClassDefFoundError: BOOT-INF/classes/OPS/package-info (wrong name: OPS/package-info)
Run Code Online (Sandbox Code Playgroud)

在具有相同 jdk1.8.0_121 的 Windows 上,它工作正常,我真的不知道可能出了什么问题。

插件配置来自pom.xml

<plugins>
    <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.2</version>
        <executions>
            <execution>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <schemaLanguage>WSDL</schemaLanguage>
            <generatePackage>OPS</generatePackage>
            <schemas>
                <schema>
                    <url>************************?wsdl</url> 
                </schema>
            </schemas>
        </configuration>
    </plugin> …
Run Code Online (Sandbox Code Playgroud)

java netbeans maven maven-jaxb2-plugin spring-boot

5
推荐指数
0
解决办法
1104
查看次数

如何告诉 Maven 不要忽略导入的 XSD 中的命名空间属性?

我正在使用 mojohaus jaxb2-maven-plugin 从 xsd 模式文件生成 Java 源。我的 pom.xml 如下所示:

...    
<plugin>

            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.5.0</version>
            <executions>
                <execution>
                    <id>xjc-1</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <packageName>my.first.package.types</packageName>
                        <sources>
                            <source>src/main/java/META-INF/wsdl/firstSchema.xsd</source>                                
                        </sources>                          
                    </configuration>
                </execution>
                <execution>
                    <id>xjc-2</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <packageName>my.second.package.types</packageName>
                        <sources>                                                       
                            <source>src/main/java/META-INF/wsdl/secondSchema.xsd</source>
                        </sources>
                        <clearOutputDir>false</clearOutputDir>              
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <outputDirectory>src/main/javagen</outputDirectory>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

该插件配置应与此处找到的配置相对应。当我运行构建时,从第一个架构生成的源文件被放入第二个包中。谁能向我解释为什么会这样?这是一个错误还是我错过了什么?

非常感谢您的任何意见!

编辑:

我也尝试了 maven-jaxb2-plugin 。结果一样!所以这似乎是一个一般的专家问题。我的 maven-jaxb2-plugin 插件配置如下:

...
            <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.14.0</version>
            <executions>
                <execution>
                    <id>first</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <schemaIncludes>
                            <include>firstSchema.xsd</include>
                        </schemaIncludes>
                        <generatePackage>my.first.package.types</generatePackage>
                    </configuration>
                </execution>
                <execution>
                    <id>second</id>
                    <goals>
                        <goal>generate</goal>
                    </goals> …
Run Code Online (Sandbox Code Playgroud)

java xjc maven maven-jaxb2-plugin jaxb2-maven-plugin

5
推荐指数
1
解决办法
1034
查看次数