maven编译异常错误loading CharSequence class file is broken

  在用maven对项目进行编译打包时,遇到了下面奇怪的编译错误

"C:\Program Files\Java\jdk1.8.0\bin\java" "-Dmaven.home=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.2.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.2.1\plugins\maven\lib\maven3\bin\m2.conf" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.2.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.2.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.2.1\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=2016.2.1 -s D:\apache-maven-3.2.5\conf\settings.xml package
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.fangdd.data:house-profile:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-install-plugin is missing. @ line 181, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing. @ line 173, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building house-profile 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce) @ house-profile ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ house-profile ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\git-repository\house-profile\src\main\resources\prod
[INFO] Copying 4 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ house-profile ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- scala-maven-plugin:3.2.2:compile (default) @ house-profile ---
[WARNING]  Expected all dependencies to require Scala version: 2.10.0
[WARNING]  com.twitter:chill_2.10:0.5.0 requires scala version: 2.10.4
[WARNING] Multiple versions of scala libraries detected!
[INFO] D:\git-repository\house-profile\src\main\java:-1: info: compiling
[INFO] D:\git-repository\house-profile\src\main\scala:-1: info: compiling
[INFO] Compiling 27 source files to D:\git-repository\house-profile\target\classes at 1498550091810
[ERROR] error: error while loading CharSequence, class file 'C:\Program Files\Java\jdk1.8.0\jre\lib\rt.jar(java/lang/CharSequence.class)' is broken
[INFO] (class java.lang.RuntimeException/bad constant pool tag 15 at byte 1501)
[ERROR] error: error while loading AnnotatedElement, class file 'C:\Program Files\Java\jdk1.8.0\jre\lib\rt.jar(java/lang/reflect/AnnotatedElement.class)' is broken
[INFO] (class java.lang.RuntimeException/bad constant pool tag 15 at byte 2713)
[ERROR] error: error while loading ConcurrentMap, class file 'C:\Program Files\Java\jdk1.8.0\jre\lib\rt.jar(java/util/concurrent/ConcurrentMap.class)' is broken
[INFO] (class java.lang.RuntimeException/bad constant pool tag 15 at byte 2447)
[ERROR] D:\git-repository\house-profile\src\main\scala\com\fangdd\data\profile\processor\ItemAddressProcessor.scala:21: error: overloaded method value replaceAllIn with alternatives:
[ERROR]   (target: CharSequence,replacer: scala.util.matching.Regex.Match => String)String <and>
[ERROR]   (target: CharSequence,replacement: String)String
[ERROR]  cannot be applied to (String, String)
[ERROR]       val addressReg = Constants.SPECIAL_CHAR_REG.r.replaceAllIn(address, "")
[ERROR]                                                     ^
[ERROR] D:\git-repository\house-profile\src\main\scala\com\fangdd\data\profile\processor\ItemNameProcessor.scala:24: error: type mismatch;
[ERROR]  found   : String
[ERROR]  required: CharSequence
[ERROR]       if (StringUtils.isNotBlank(name)) {
[ERROR]                                  ^
[ERROR] D:\git-repository\house-profile\src\main\scala\com\fangdd\data\profile\processor\ItemNameProcessor.scala:44: error: type mismatch;
[ERROR]  found   : String
[ERROR]  required: CharSequence
[ERROR]       if (StringUtils.isNotBlank(name)) {
[ERROR]                                  ^
[ERROR] D:\git-repository\house-profile\src\main\scala\com\fangdd\data\profile\processor\ItemNameProcessor.scala:55: error: overloaded method value indexOf with alternatives:
[ERROR]   (CharSequence,CharSequence)Int <and>
[ERROR]   (CharSequence,Int)Int
[ERROR]  cannot be applied to (String, String)
[ERROR]          val baseName = StringUtils.substring(tmp1, 0, StringUtils.indexOf(tmp1, ""))
[ERROR]                                                                    ^
[ERROR] error: error while loading Pattern, class file 'C:\Program Files\Java\jdk1.8.0\jre\lib\rt.jar(java/util/regex/Pattern.class)' is broken
[INFO] (class java.lang.RuntimeException/bad constant pool tag 15 at byte 14717)
[ERROR] D:\git-repository\house-profile\src\main\scala\com\fangdd\data\profile\processor\ItemNameProcessor.scala:127: error: type mismatch;
[ERROR]  found   : String
[ERROR]  required: CharSequence
[ERROR]             if (StringUtils.equals(srcNameNormalized, tgtNameNormalized)) {
[ERROR]                                    ^
[ERROR] D:\git-repository\house-profile\src\main\scala\com\fangdd\data\profile\util\ItemAddressProcessor.scala:22: error: overloaded method value replaceAllIn with alternatives:
[ERROR]   (target: CharSequence,replacer: scala.util.matching.Regex.Match => String)String <and>
[ERROR]   (target: CharSequence,replacement: String)String
[ERROR]  cannot be applied to (String, String)
[ERROR]       val addressReg = Constants.SPECIAL_CHAR_REG.r.replaceAllIn(address, "")
[ERROR]                                                     ^
[ERROR] 10 errors found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.241s
[INFO] Finished at: Tue Jun 27 15:54:55 CST 2017
[INFO] Final Memory: 19M/259M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile (default) on project house-profile: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Process finished with exit code 1

最后发现是maven编译插件配置的原因,编译插件版本不完整配置的是scala.binary.version,应该采用完整版本scala.complete.version才能找到具体的class

 <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <maven.version.min>3.0.5</maven.version.min>
        <scala.binary.version>2.11</scala.binary.version>
        <scala.complete.version>${scala.binary.version}.4</scala.complete.version>
        <spark.version>1.6.2</spark.version>
        <spark-sql.version>1.6.2</spark-sql.version>
        <spark-hive.version>1.6.2</spark-hive.version>
 </properties>

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <version>3.2.2</version>
    <configuration>
        <scalaVersion>${scala.complete.version}</scalaVersion>
        <args>
            <arg>-unchecked</arg>
            <arg>-deprecation</arg>
            <arg>-feature</arg>
        </args>
        <javacArgs>
            <javacArg>-source</javacArg>
            <javacArg>${java.version}</javacArg>
            <javacArg>-target</javacArg>
            <javacArg>${java.version}</javacArg>
        </javacArgs>
    </configuration>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值