有没有一种通用的方法可以在 pom.xml 中设置 -D 参数?
Is there a generic way to set -D arguments from within a pom.xml?
tl;dr: 那么,有没有办法移动 -D
系统 属性 的定义并将其内化到 pom.xml
文件?
我们目前从命令行将 -Djavax.xml.accessExternalSchema=all
作为 mvn clean install -Djavax.xml.accessExternalSchema=all
传递,以使我的构建能够工作。我无法通过插件中的选项 (jaxb2-maven-plugin 1.6),因为我们使用的版本不支持此功能,而支持的版本需要完全更改配置,我们不会为此获得批准。
尝试通过在 <project>
标签下添加来设置在 <properties>
中使用标签的值,如 suggested elsewhere:
<properties>
<javax.xml.accessExternalSchema>all</javax.xml.accessExternalSchema>
</properties>
但我仍然收到错误(转载如下),而通过命令行传递它却没有。
Caused by: org.xml.sax.SAXParseException;
systemId: jar:file:/e:/apache/maven/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.2.7/jaxb-xjc-2.2.7.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd;
lineNumber: 52; columnNumber: 88; schema_reference:
Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.
是的,您可以使用 Properties Maven plugin using the set-system-properties
goal which will set it during the initialize
phase。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>all</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
出于某种原因,这里接受的答案(以及我在网上找到的许多其他解决方案)对我不起作用。
对于遇到同样问题的其他人,maven-surefire-plugin
可能还会提供解决方案:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<javax.xml.accessExternalSchema>all</javax.xml.accessExternalSchema>
</systemPropertyVariables>
</configuration>
</plugin>
tl;dr: 那么,有没有办法移动 -D
系统 属性 的定义并将其内化到 pom.xml
文件?
我们目前从命令行将 -Djavax.xml.accessExternalSchema=all
作为 mvn clean install -Djavax.xml.accessExternalSchema=all
传递,以使我的构建能够工作。我无法通过插件中的选项 (jaxb2-maven-plugin 1.6),因为我们使用的版本不支持此功能,而支持的版本需要完全更改配置,我们不会为此获得批准。
尝试通过在 <project>
标签下添加来设置在 <properties>
中使用标签的值,如 suggested elsewhere:
<properties>
<javax.xml.accessExternalSchema>all</javax.xml.accessExternalSchema>
</properties>
但我仍然收到错误(转载如下),而通过命令行传递它却没有。
Caused by: org.xml.sax.SAXParseException;
systemId: jar:file:/e:/apache/maven/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.2.7/jaxb-xjc-2.2.7.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd;
lineNumber: 52; columnNumber: 88; schema_reference:
Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.
是的,您可以使用 Properties Maven plugin using the set-system-properties
goal which will set it during the initialize
phase。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>all</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
出于某种原因,这里接受的答案(以及我在网上找到的许多其他解决方案)对我不起作用。
对于遇到同样问题的其他人,maven-surefire-plugin
可能还会提供解决方案:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<javax.xml.accessExternalSchema>all</javax.xml.accessExternalSchema>
</systemPropertyVariables>
</configuration>
</plugin>