您必须创建一个绑定文件来强制生成 simpleType:
http: //docs.oracle.com/cd/E17802_01/webservices/webservices/docs/1.5/tutorial/doc/JAXBUsing4.html
您应该尝试javaType
声明。
我之前只做过枚举,所以我可以给你一个例子:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:annox="http://annox.dev.java.net"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
version="2.1">
<jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:complexType[@name='sometype']//xs:element[@name='Percentage']/xs:simpleType">
<jaxb:typesafeEnumClass name="Percentage"></jaxb:typesafeEnumClass>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
如果您使用的是 maven,则应将这些行添加到 jaxb 插件的配置中:
<bindingDirectory>src/main/schema</bindingDirectory>
<bindingIncludes>
<include>**/*.xjb</include>
</bindingIncludes>