1
Apache POI通常通過Ant進行編譯,並且有一些步驟使用xmlbeans-Ant任務將OfficeOpenXML Schema轉換爲代碼。XMLBeans在通過Ant和Maven運行時創建不同的代碼
我目前正在構建相應的一組Maven pom.xml文件,這些文件也編譯代碼以便更輕鬆地在Apache POI上運行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的產生不同的吸氣劑,注意名稱不同的方法:
/**
* Gets the "encryptedKey" element
*/
com.microsoft.schemas.office.x2006.keyEncryptor.password.CTPasswordKeyEncryptor
getEncryptedKey();
有沒有什麼辦法可以解決這個問題?據我所見,使用了完全相同的源代碼-XSD,儘管我對XMLBeans知之甚少,所以在這裏可能會使用一些不同的設置...
一個明顯的問題。您是否使用相同版本的XMLbeans?檢查ANT構建。 –
是的,它的兩側是2.3.0,我用2.6.0驗證,也沒有運氣...... – centic
對不起,多米尼克,我剛剛看到這個問題,從我們的聲納來源鏈接。方法命名由.xsdconfig文件(encryptionCertificate.xsdconfig和encryptionPassword.xsdconfig)配置。我還沒有檢查過它,但似乎螞蟻有一個不同於maven的查找目錄。 – kiwiwings