maven-site-plugin An API incompatibility was encountered问题及编码utf-8/gbk 的不可映射字符
?按照百度文库上一篇文章(http://wenku.baidu.com/view /0477e440a8956bec0975e394.html)配置maven?site?plugin,当将版本号由3.0-beta-3改为 3.0?运行?mvn?site?时出现错 误:An?API?incompatibility?was?encountered?while?executing org.apache.maven.plugins:maven-site-plugin:3.0:site。该错误详细信息如下:
?
?
realm?=????plugin>org.apache.maven.plugins:maven-site-plugin:3.0strategy?=?org.codehaus.plexus.classworlds.strategy.SelfFirstStrategyurls[0]?=file:/Users/nodje/.m2/repository/org/apache/maven/plugins/maven-site-plugin/3.0/maven-site-plugin-3.0.jarurls[1]?=file:/Users/nodje/.m2/repository/org/apache/maven/reporting/maven-reporting-exec/1.0.1/maven-reporting-exec-1.0.1.jarurls[2]?=file:/Users/nodje/.m2/repository/org/apache/maven/reporting/maven-reporting-api/3.0/maven-reporting-api-3.0.jarurls[3]?=file:/Users/nodje/.m2/repository/org/apache/velocity/velocity/1.5/velocity-1.5.jarurls[4]?=?file:/Users/nodje/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jarurls[5]?=file:/Users/nodje/.m2/repository/velocity/velocity/1.5/velocity-1.5.jarurls[6]?=file:/Users/nodje/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jarurls[7]?=file:/Users/nodje/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jarurls[8]?=file:/Users/nodje/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jarurls[9]?=file:/Users/nodje/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jarurls[10]?=file:/Users/nodje/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jarurls[11]?=file:/Users/nodje/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jarurls[12]?=file:/Users/nodje/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jarurls[13]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.2/doxia-sink-api-1.2.jarurls[14]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.2/doxia-logging-api-1.2.jarurls[15]?=file:/Users/nodje/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jarurls[16]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-core/1.2/doxia-core-1.2.jarurls[17]?=file:/Users/nodje/.m2/repository/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jarurls[18]?=file:/Users/nodje/.m2/repository/xml-apis/xml-apis/1.3.04/xml-apis-1.3.04.jarurls[19]?=file:/Users/nodje/.m2/repository/org/apache/httpcomponents/httpclient/4.0.2/httpclient-4.0.2.jarurls[20]?=file:/Users/nodje/.m2/repository/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jarurls[21]?=file:/Users/nodje/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jarurls[22]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-module-xhtml/1.2/doxia-module-xhtml-1.2.jarurls[23]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-module-apt/1.2/doxia-module-apt-1.2.jarurls[24]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-module-xdoc/1.2/doxia-module-xdoc-1.2.jarurls[25]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-module-fml/1.2/doxia-module-fml-1.2.jarurls[26]?=file:/Users/nodje/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jarurls[27]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-decoration-model/1.2/doxia-decoration-model-1.2.jarurls[28]?=file:/Users/nodje/.m2/repository/org/apache/maven/doxia/doxia-site-renderer/1.2/doxia-site-renderer-1.2.jarurls[29]?=file:/Users/nodje/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jarurls[30]?=file:/Users/nodje/.m2/repository/org/apache/maven/shared/maven-doxia-tools/1.4/maven-doxia-tools-1.4.jarurls[31]?=file:/Users/nodje/.m2/repository/org/codehaus/plexus/plexus-archiver/1.0/plexus-archiver-1.0.jarurls[32]?=file:/Users/nodje/.m2/repository/org/codehaus/plexus/plexus-io/1.0/plexus-io-1.0.jarurls[33]?=file:/Users/nodje/.m2/repository/org/codehaus/plexus/plexus-i18n/1.0-beta-7/plexus-i18n-1.0-beta-7.jarurls[34]?=file:/Users/nodje/.m2/repository/org/codehaus/plexus/plexus-velocity/1.1.8/plexus-velocity-1.1.8.jarurls[35]?=file:/Users/nodje/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.10/plexus-utils-1.5.10.jarurls[36]?=file:/Users/nodje/.m2/repository/org/mortbay/jetty/jetty/6.1.25/jetty-6.1.25.jarurls[37]?=file:/Users/nodje/.m2/repository/org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jarurls[38]?=file:/Users/nodje/.m2/repository/org/mortbay/jetty/jetty-util/6.1.25/jetty-util-6.1.25.jarurls[39]?=file:/Users/nodje/.m2/repository/commons-lang/commons-lang/2.5/commons-lang-2.5.jarurls[40]?=file:/Users/nodje/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jarNumber?of?foreign?imports:?1import:?Entry[import??from?realm?ClassRealm[maven.api,?parent:?null]]
?????(参见:http://comments.gmane.org/gmane.comp.jakarta.turbine.maven.user/123151)??与该文错误一致。
?
???????按照上文描述,可能是由于maven版本变换引起的问题,Plugins?Compatibility?Matrix?for?Maven?3中 有对Maven?3下maven-site-plugin可使用插件版本的要求。另外一个问题是,文库(http://wenku.baidu.com /view/0477e440a8956bec0975e394.html)中使用的是:jxr-maven-plugin?插件:
<plugin>?????????
?????<groupId>org.codehaus.mojo</groupId>??????????
????<artifactId>jxr-maven-plugin</artifactId>?????????
</plugin>
?
??????将其修改成:
?
<plugin>?????????
?????<groupId>org.apache.maven.plugins</groupId>??????????
??????<artifactId>maven-jxr-plugin</artifactId>?
</plugin>
?
??????并确认Maven?3下maven-site-plugin各插件版本是否符合要求,再次运行?mvn?clean?site命令即可编译成功。
?
????另在运行mvn?site?时出现”编码utf-8/gbk?的不可映射字符“的?警告,导致生成的apidocs中的汉字是乱码。需要将工程编码格式设置成UTF-8(选中项目——>Project——》Properties?——》Resource——》Text?file?encoding——》Other:UTF-8),并在pom.xml中进行相应配置:
1)
<build>
??????<pluginManagement>
??????????<plugins>
??????????????<plugin>
?????????????????<groupId>org.apache.maven.plugins</groupId>
?????????????????<artifactId>maven-compiler-plugin</artifactId>
?????????????????<version>2.3.2</version>
?????????????????<configuration>
?????????????????????<source>1.5</source>
?????????????????????<encoding>UTF-8</encoding>
?????????????????</configuration>
??????????????</plugin>
??????????</plugins>
??????</pluginManagement>
??</build>
?
2)
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
?
3)
<build>
???<pluginManagement>
??????????<plugins>
??????????????<plugin>
?????????????????<groupId>org.apache.maven.plugins</groupId>
?????????????????<artifactId>maven-site-plugin</artifactId>
?????????????????<version>3.0</version>
?????????????????<configuration>
?????????????????????<locales>zh_CN</locales>
?????????????????????<outputEncoding>UTF-8</outputEncoding>
???????????????????????............................
????????????????</configuration>
??????????????</plugin>
??????????</plugins>
??????</pluginManagement>
??</build>