Maven maven-jaxb2-plugin 和 HTTP 302

Maven maven-jaxb2-plugin and HTTP 302

我正在使用 Maven 3.3.3 和 maven-jaxb2-plugin 版本 0.12.1 从 XSD 模式生成 java 类。 XSD 为 returns 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 以正确 link 或不去尝试下载 XSD?

我使用 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>

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

您遇到了以下问题:

  • URLConnection Doesn't Follow Redirect

也就是by design.

您使用 catalogs 的解决方案是正确的。但是您很可能不需要 ClasspathCatalogResolver.