Apache通常通过Ant进行编译,并有一些步骤,其中使用xmlbeans-Ant-任务将OfficeOpenXML模式转换为代码。
我目前正在构建相应的Maven pom.xml文件集,该文件还编译代码,以便更容易地在Apache上运行Sonar检查。
但是,在XMLBeans生成代码时,一些生成的类看起来不同。
在Ant文件中,语句是:
<xmlbean
schema="${ooxml.encryption.xsd.dir}"
srcgendir="${ooxml.encryption.src.dir}"
optimize="yes"
destfile="${ooxml.encryption.jar}"
javasource="1.5"
failonerror="true"
fork="true"
memoryMaximumSize="${ooxml.memory}"
>
<classpath refid="ooxml.classpath"/>
</xmlbean>在Maven中我使用
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>target/schemas</schemaDirectory>
<javaSource>1.5</javaSource>
<optimize>yes</optimize>
</configuration>
</plugin>大多数类是相等的,但是有不同的名称getter/setter,即
蚂蚁生产
/**
* Gets the "encryptedKey" element
*/
com.microsoft.schemas.office.x2006.keyEncryptor.password.CTPasswordKeyEncryptor
getEncryptedPasswordKey();但是Maven生成了一个不同的getter,请注意命名不同的方法:
/**
* Gets the "encryptedKey" element
*/
com.microsoft.schemas.office.x2006.keyEncryptor.password.CTPasswordKeyEncryptor
getEncryptedKey();有什么办法能解决这个问题吗?据我所见,使用的是完全相同的源代码-XSD,虽然我对XMLBeans知之甚少,所以这里使用的可能是一些不同的设置.
发布于 2015-08-17 23:39:10
只是为了完满..。可以通过将以下内容添加到配置部分来解决这一问题:
<xmlConfigs>
<xmlConfig implementation="java.io.File">../../src/ooxml/resources/org/apache/poi/poifs/crypt</xmlConfig>
</xmlConfigs>..。因此,ant任务在与.xsdconfig相同的dir中查找.xsds文件,但是需要显式地指示maven .
https://stackoverflow.com/questions/21796000
复制相似问题