accessExternalDTD 属性 忽略目录文件
accessExternalDTD property ignoring catalog file
当运行 mvn clean install 时,出现以下错误,无法访问外部文件。
schema_reference: Failed to read schema document 'xml.xsd', because 'http' access is not allowed due to restriction set by the accessExternalSchema property.
此行为符合预期,因为我希望我的资源是本地的。但是目录更改不应该避免这个错误吗?还是我的配置有问题?
部分 pom 文件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<catalog>${project.basedir}/catalog.xml</catalog>
<schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</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</value>
</property>
<property>
<name>javax.xml.accessExternalDTD</name>
<value>file</value>
</property>
</properties>
<outputFile/>
</configuration>
</plugin>
目录文件:
<!DOCTYPE catalog
PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem systemIdStartString="http://www.w3.org/XML/1998/namespace" rewritePrefix="www.w3.org"/>
</catalog>
我遇到了类似的错误,我尝试了太多找到的解决方案,但唯一对我有用的是:
将此添加到插件标签中的 pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<javax.xml.accessExternalSchema>all</javax.xml.accessExternalSchema>
</systemPropertyVariables>
</configuration>
</plugin>
抱歉我的英语不好,我希望这对你有用
经过大量试验,我发现我的目录是错误的。
的使用
<property>
<name>javax.xml.accessExternalSchema</name>
<value>file</value>
</property>
<property>
<name>javax.xml.accessExternalDTD</name>
<value>file</value>
</property>
已删除,我将目录更改为 catalog.cat 文件,格式为 catalog.xml,更改为:
REWRITE_SYSTEM "http://www.w3.org" "www.w3.org"
REWRITE_SYSTEM "http://docs.oasis-open.org" "docs.oasis-open.org"
REWRITE_URI "http://docs.oasis-open.org/wsn" "docs.oasis-open.org/wsn"
REWRITE_URI "http://docs.oasis-open.org/wsrf" "docs.oasis-open.org/wsrf"
上面提到的属性确实适用于此目录,但我放弃了它,因为对于工作目录,只要目录中的路径正确,maven 就不会获取任何外部模式。使属性过时。
当运行 mvn clean install 时,出现以下错误,无法访问外部文件。
schema_reference: Failed to read schema document 'xml.xsd', because 'http' access is not allowed due to restriction set by the accessExternalSchema property.
此行为符合预期,因为我希望我的资源是本地的。但是目录更改不应该避免这个错误吗?还是我的配置有问题?
部分 pom 文件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<catalog>${project.basedir}/catalog.xml</catalog>
<schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</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</value>
</property>
<property>
<name>javax.xml.accessExternalDTD</name>
<value>file</value>
</property>
</properties>
<outputFile/>
</configuration>
</plugin>
目录文件:
<!DOCTYPE catalog
PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem systemIdStartString="http://www.w3.org/XML/1998/namespace" rewritePrefix="www.w3.org"/>
</catalog>
我遇到了类似的错误,我尝试了太多找到的解决方案,但唯一对我有用的是:
将此添加到插件标签中的 pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<javax.xml.accessExternalSchema>all</javax.xml.accessExternalSchema>
</systemPropertyVariables>
</configuration>
</plugin>
抱歉我的英语不好,我希望这对你有用
经过大量试验,我发现我的目录是错误的。
的使用<property>
<name>javax.xml.accessExternalSchema</name>
<value>file</value>
</property>
<property>
<name>javax.xml.accessExternalDTD</name>
<value>file</value>
</property>
已删除,我将目录更改为 catalog.cat 文件,格式为 catalog.xml,更改为:
REWRITE_SYSTEM "http://www.w3.org" "www.w3.org"
REWRITE_SYSTEM "http://docs.oasis-open.org" "docs.oasis-open.org"
REWRITE_URI "http://docs.oasis-open.org/wsn" "docs.oasis-open.org/wsn"
REWRITE_URI "http://docs.oasis-open.org/wsrf" "docs.oasis-open.org/wsrf"
上面提到的属性确实适用于此目录,但我放弃了它,因为对于工作目录,只要目录中的路径正确,maven 就不会获取任何外部模式。使属性过时。