当在自定义的maven插件的工程目录下执行mvn clean install 时,抛出以下异常,由于抛出的异常行数为313行,但所指定的源代码文件中行数少于313行,不得其解。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:2.6:descriptor (default-descriptor) on proj ct maven-codegen-plugin: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:2.6:descript r failed: syntax error @[313,1] in file...... |
于我就使用mvn clean install -e 将异常的详细信息打印出来,内容如下:
at com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:1018) at com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:1324) at com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:999) at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:353) at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:381) at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:377) at com.thoughtworks.qdox.JavaDocBuilder$2.visitFile(JavaDocBuilder.java:467) |
从里面可以看出语法分析器说语法错误,但我在eclipse工程里面clean项目,IDE没有发现语法异常,我就觉得是中文编码的问题,于是我在项目的pom.xml中添加以下的插件配置信息:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugin-plugin</artifactId> <version>2.6</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> |
再次mvn clean install,就看到以下让人愉悦的信息了。
[INFO] ----------------- [INFO] BUILD SUCCESS [INFO] ----------------- |