简体   繁体   English

Gradle-使用jaxb生成可序列化的类

[英]Gradle - Generating serializable classes with jaxb

I'm using gradle as build tool and configuring jaxb plugin jacobono. 我正在使用gradle作为构建工具并配置jaxb插件jacobono。 Have the below entry in build.gradle file: 在build.gradle文件中具有以下条目:

jaxb {
  bindingsDir = "src/main/resources/xjb"
  xjc {
   xsdDir = "src/main/resources/xsd"
   generatePackage = "some.package"
  }
}

under xjb directory, have binding.xml with the below content: 在xjb目录下,具有具有以下内容的binding.xml:

<?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"
        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
        xsi:schemaLocation="
 http://java.sun.com/xml/ns/jaxb      
 http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
 version="2.1">
   <globalBindings>
     <serializable uid="1" />
   </globalBindings>
 </bindings>

Although the files are getting generated, none of them implements serializable interface as i have defined in binding xml. 尽管正在生成文件,但是它们都没有实现我在绑定xml中定义的可序列化接口。 I doubt on the binding dir configurations. 我对绑定目录配置感到怀疑。

Any advice will be much helpful. 任何建议将大有帮助。

Moved the binding information to xsds, and it worked. 将绑定信息移动到xsds,并且可以正常工作。

Not sure whether the plugin works properly with binging dir paramter as it didnt work even with absolute path. 不确定插件是否可以使用binging dir参数,因为即使使用绝对路径也无法正常工作。

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

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