0
jaxb2-maven-plugin 1.6을 사용하여 Spring MVC 프로젝트에 구현 된 API 용 Java 객체를 생성합니다.들여 쓰기가 중복 된 JAXB 목록의 XSD
<complexType name="UserPrivilege">
<sequence>
<element name="Id" type="string"></element>
<element name="Name" type="string"></element>
<element name="Method" type="string"></element>
<element name="Path" type="string"></element>
</sequence>
</complexType>
<complexType name="UserPrivilegeList">
<sequence>
<element name="Privilege" type="myapi:UserPrivilege" minOccurs="0" maxOccurs="unbounded" />
</sequence>
</complexType>
<complexType name="UserRole">
<sequence>
<element name="Id" type="string"></element>
<element name="Name" type="string"></element>
<element name="Privileges" type="myapi:UserPrivilegeList"></element>
</sequence>
</complexType>
이 내입니다 : 이것은 내 XSD 정의입니다
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="2.1"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns="http://www.w3.org/2001/XMLSchema">
<jaxb:globalBindings>
<jaxb:serializable uid="1"/>
</jaxb:globalBindings>
</jaxb:bindings>
:이 바인딩 지구 내 JAXB입니다
<!-- JAXB 2 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>set-additional-system-properties</id>
<goals>
<goal>set-system-properties</goal>
</goals>
</execution>
</executions>
<configuration>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>file,http</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>api</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<xjbSources>
<xjbSource>${basedir}/src/main/resources/xsd/api/api.xjb</xjbSource>
</xjbSources>
<sources>
<source>${basedir}/src/main/resources/xsd/api/api.xsd</source>
</sources>
<packageName>com.example.ems.aaa.xsd.api</packageName>
</configuration>
</plugin>
:
이 내 pom.xml 파일의 JAXB 섹션입니다 응답 인스턴스 :
<UserRole>
<id>17b55c53-7328-4444-95e2-648fb5f9de89</id>
<name>CONFIGURATOR</name>
<privileges>
<privilege>
<privilege>
<id>b5f7f39a-f87c-4874-9b16-381a5e0613b3</id>
<name>CONFIG_PUT</name>
<method>PUT</method>
<path>/config/**</path>
</privilege>
<privilege>
<id>7045c699-5608-4584-a3d0-41a96b9d7903</id>
<name>CONFIG_GET</name>
<method>GET</method>
<path>/config/**</path>
</privilege>
</privilege>
</privileges>
</UserRole>
당신이 목록의 XML 중복 이름 들여 쓰기를 볼 수 있다면 : 나는
<privileges>
<privilege>
<privilege>
방지 할 수 있습니까?
다른 complexType의 다른 시퀀스에서 요소로 사용하기 때문에 "UserRole"을 complexType으로 정의해야합니다.
인사말.