Maven maven-jaxb2-plugin和HTTP 302

时间:2015-10-07 09:33:21

标签: maven jaxb maven-jaxb2-plugin

我正在使用Maven 3.3.3和maven-jaxb2-plugin版本0.12.1从XSD架构生成java类。 XSD返回HTTP 302的地址和插件抛出:

[ERROR] Error while parsing schema(s).Location [ http://www.gzs.si/e-poslovanje/sheme/eSlog_1-5_EnostavniRacun_signature.xsd{1,30}].
org.xml.sax.SAXParseException; systemId: http://www.gzs.si/e-poslovanje/sheme/eSlog_1-5_EnostavniRacun_signature.xsd; lineNumber: 1; columnNumber: 30; s4s-elt-character: Non-whitespace characters are not allowed in schema elements o
ther than 'xs:appinfo' and 'xs:documentation'. Saw 'Document Moved'.

是否可以指定xjc编译器如何跟随302到正确的链接以及尝试下载XSD?

2 个答案:

答案 0 :(得分:0)

我通过使用catalog.xml解决了这个问题:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>                                                                                                                                                                                  
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">                                                                                                                                                           
     <rewriteSystem systemIdStartString="http://www.gzs.si" rewritePrefix="https://www.gzs.si"/>                                                                                                                                        
</catalog>

然后在我的pom.xml中:

<plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.12.1</version>
                <executions>
                    ...
                </executions>
                <configuration>
                    <strict>false</strict>
                    <catalog>src/main/resources/jaxb/catalog.xml</catalog>
                    <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver>
                    <generateDirectory>${project.build.directory}/generated-sources/xjc</generateDirectory>
                    <verbose>true</verbose>
                </configuration>
            </plugin>

答案 1 :(得分:0)

免责声明:此处maven-jaxb2-plugin的作者。

您遇到了以下问题:

哪个是by design

catalogs的解决方案是正确的。但你很可能不需要ClasspathCatalogResolver