2
2 개의 maven 모듈이 있습니다.annox 사용자 정의가있는 JAXB 별도의 에피소드가 실패합니다. SAXParseException2
-
처음에는 기본 POJO 클래스를 생성하는 xsd 스키마 만 포함되어 있습니다.
- 두 번째에는 카탈로그 파일로 첫 번째 파일을 가져오고 새 POJO 클래스를 생성하는 xsd 스키마가 들어 있습니다. 두 세대 모두 작동합니다.
이제 annox (Swagger 주석)를 사용하여 xsd 파일에 주석을 추가합니다. 첫 번째 모듈 컴파일이 성공했지만 초 모듈 컴파일이 실패하고 예외 :
[ERROR] Error while generating code.Location : com.sun.istack.SAXParseException2; systemId: jar:file:/C:/commons-0.0.1-SNAPSHOT.jar!/Commons.xsd; lineNumber: 15; columnNumber: 36; compiler was unable to honor annox:annotate schemaBinding customization. It is attached to a wrong place, or its inconsistent with other bindings.
첫 번째 모듈
'Commons.xsd'
<?xml version="1.0" encoding="UTF-8" ?> <xs:schema xmlns="http://www.test.com/commons" targetNamespace="http://www.test.com/commons" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:annox="http://annox.dev.java.net" xmlns:swagger="http://annox.dev.java.net/com.wordnik.swagger.annotations" xmlns:xs="http://www.w3.org/2001/XMLSchema" jaxb:extensionBindingPrefixes="annox" jaxb:version="2.1"> <xs:complexType name="BaseType"> <xs:annotation> <xs:appinfo> <annox:annotate target="class"> <swagger:ApiModel value="BaseType" description="Description" /> </annox:annotate> </xs:appinfo> </xs:annotation> <xs:sequence> <xs:element name="field1" type="xs:integer"/> </xs:sequence> </xs:complexType> </xs:schema>
'치어 .xml ':
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>test</groupId> <artifactId>commons</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <dependencies> <dependency> <groupId>com.wordnik</groupId> <artifactId>swagger-annotations</artifactId> <version>1.3.2</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.8.3</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <args> <arg>-Xannotate</arg> </args> <plugins> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics</artifactId> <version>0.6.5</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics-annotate</artifactId> <version>0.6.5</version> </plugin> </plugins> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>com.wordnik</groupId> <artifactId>swagger-annotations</artifactId> <version>1.3.2</version> </dependency> </dependencies> </plugin> </plugins> </build> </project>
2 모듈
'Extension.xsd'
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://www.test.com/extension" targetNamespace="http://www.test.com/extension" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:annox="http://annox.dev.java.net" xmlns:swagger="http://annox.dev.java.net/com.wordnik.swagger.annotations" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:c="http://www.test.com/commons" elementFormDefault="unqualified" attributeFormDefault="unqualified" jaxb:extensionBindingPrefixes="annox" jaxb:version="2.1"> <xs:import namespace="http://www.test.com/commons" schemaLocation="Commons.xsd" /> <xs:complexType name="Extension"> <xs:annotation> <xs:appinfo> <annox:annotate target="class"> <swagger:ApiModel value="Extension" description="Description" /> </annox:annotate> </xs:appinfo> </xs:annotation> <xs:complexContent> <xs:extension base="c:BaseType"> <xs:sequence> <xs:element name="field2" type="xs:integer" /> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> </xs:schema>
'의 pom.xml'
,977,885,321 0<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>test</groupId> <artifactId>extension</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <dependencies> <dependency> <groupId>test</groupId> <artifactId>commons</artifactId> <version>${project.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.8.3</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <args> <arg>-Xannotate</arg> </args> <episodes> <episode> <groupId>test</groupId> <artifactId>commons</artifactId> </episode> </episodes> <catalog>src/main/resources/catalog.xml</catalog> <plugins> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics</artifactId> <version>0.6.5</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics-annotate</artifactId> <version>0.6.5</version> </plugin> </plugins> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>com.wordnik</groupId> <artifactId>swagger-annotations</artifactId> <version>1.3.2</version> </dependency> </dependencies> </plugin> </plugins> </build> </project>
'catalog.xml'!
<?xml version="1.0" encoding="UTF-8"?> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <systemSuffix systemIdSuffix="Commons.xsd" uri="maven:test:commons!/Commons.xsd" /> </catalog>
그것은 성공없이 내가 해결하기 위해 노력하고있어 일이 오류가있었습니다.
이다, 순간에 액세스 할 수없는 것 같다. – lexicore
나는 가능한 해결책을 여기에서 발견했다 : https://java.net/projects/jaxb/lists/users/archive/2009-06/message/107 –
좋아, Alexey Valikov와 나도 같은 사람이다. :) – lexicore