[英]How to specify javax.xml.accessExternalSchema for the JAXB2 Maven plugin
我有一个 maven 插件 (jaxb2),我需要为其提供一个 jvm arg。 我不认为有一个标签可以在它的 pom 中添加 jvm args。
我知道我可以在命令行上传入 jvm 参数,例如: mvn clean install -Djavax.xml.accessExternalSchema=all
是否可以在 pom 中设置这个 jvm arg,这样我就不必每次都在命令行中输入它了?
(另外 - 这个 jvm arg 是必需的,以便它与 JAVA-8 一起工作。它与 JAVA-7 一起工作正常)
这与Java 8中引入的JAXB 1.5中的新XML安全属性相关。这就是为什么您的构建现在在Java 8上失败但与Java 7一起使用。
如果您正在使用我的maven-jaxb2-plugin
,请升级到0.9.0
或更高版本(当前为0.10.0
)。 它现在有一个accessExternalSchema
开关(默认为all
)。
这精确地设置了javax.xml.accessExternalSchema=all
。
请参阅文档 。
我在使用jaxb2-maven-plugin时遇到了这个问题。 我找到了maven-jabx2-plugin的相关jira问题 - https://java.net/projects/maven-jaxb2-plugin/lists/issues/archive/2014-03/message/0
根据这个问题,Stephan202建议使用像魅力一样的属性-maven-plugin。 这是他的帖子中的示例代码 -
<plugin>
<!-- We use this plugin to ensure that our usage of the
maven-jaxb2-plugin is JDK 8 compatible in absence of a fix
for https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-80. -->
<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,http</value>
</property>
</properties>
</configuration>
</plugin>
回覆; 帖子 - “我需要一个不使用alpha版本的解决方案,因为这是我的公司规则。”
将版本更改为1.0并将值更改为“all”使其适用于我:
<plugin>
<!-- We use this plugin to ensure that our usage of the
maven-jaxb2-plugin is JDK 8 compatible in absence of a fix
for https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-80. -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<!--
<version>1.0-alpha-2</version> -->
<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>all</value>
</property>
</properties>
</configuration>
</plugin>
它对我有用:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<vmArgs>
<arg>-Djavax.xml.accessExternalSchema=all</arg>
</vmArgs>
<keep>true</keep>
<verbose>true</verbose>
<wsdlDirectory>${project.build.directory}/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>ServiceWsService.wsdl</wsdlFile>
</wsdlFiles>
<bindingFiles>
<bindingFile>custom-binding.xml</bindingFile>
<bindingFile>custom-binding2.xml</bindingFile>
</bindingFiles>
</configuration>
</execution>
</executions>
</plugin>
看看Maven编译器插件。 具体来说,您应该能够使用<compilerArgument>
元素将设置传递给编译器。
有关示例,请参见http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html 。
如果您尝试更改运行Maven本身的JVM的行为,请在启动mvn之前向环境中的MAVEN_OPTS添加选项。
对于maven-jaxb2-plugin
版本2.5.0
试图从DTD
生成并随地吐痰
org.xml.sax.SAXParseException:外部解析被禁用。 无法解析 URI:...
它有助于将以下内容添加到插件配置中
<configuration>
...
<externalEntityProcessing>true</externalEntityProcessing>
</configuration>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.