3

tl;dr:那么,有没有办法移动-D系统属性的定义并将其内部化到pom.xml文件中?


我们目前正在-Djavax.xml.accessExternalSchema=all从命令行传递mvn clean install -Djavax.xml.accessExternalSchema=all以使我的构建工作。我无法通过插件(jaxb2-maven-plugin 1.6)中的选项,因为我们使用的版本不支持此功能,并且需要完全更改配置的版本,我们不会获得批准。

尝试通过在标签下添加来设置在<properties>其他地方建议<project>的使用标签的值:

<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.
4

2 回答 2

8

是的,您可以使用将在阶段设置它的目标来使用Properties Maven 插件set-system-propertiesinitialize

<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>
于 2015-12-17T16:54:08.433 回答
0

出于某种原因,这里接受的答案(以及我在网上找到的许多其他解决方案)对我不起作用。对于其他有同样问题的人,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>
于 2017-04-13T11:07:48.263 回答