包装时的Maven NumberFormatException

时间:2018-02-10 18:00:31

标签: java maven

在项目上运行mvn package(或mvn install / deploy)时,我的Windows PC上出现了一个非常奇怪的错误。此错误仅发生在此计算机上,一切正常,在我的笔记本电脑和其他计算机上。我曾经能够毫无问题地打包/安装项目,但现在甚至更旧的提交和分支都会抛出此异常。

java.lang.NumberFormatException: For input string: "34m[[["
    at java.lang.NumberFormatException.forInputString(NumberFormatException java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.<init>(Integer.java:867)
    at org.fusesource.jansi.AnsiOutputStream.write(AnsiOutputStream.java:12)
    at java.io.FilterOutputStream.write(FilterOutputStream.java:125)
    at java.io.PrintStream.write(PrintStream.java:480)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
    at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
    at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
    at java.io.PrintStream.write(PrintStream.java:526)
    at java.io.PrintStream.print(PrintStream.java:669)
    at java.io.PrintStream.println(PrintStream.java:806)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:423)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Console error screenshot

我正在使用Maven 3.5.2和Java 1.8.0_91。我已经尝试重新安装Maven。

我发现this SO帖子显然有类似问题,但没有发布解决方案 任何人都知道可能导致这种情况的原因是什么?

如果我使用mvn clean install -B运行它会对整个控制台日志产生以下错误:
at org.codehaus.plexus.archiver.AbstractArchiver$1.hasNext(AbstractArchiver.java:467)
(screenshot)

这是我的POM文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>****</groupId>
    <artifactId>sniffer</artifactId>
    <version>0.6-SNAPSHOT</version>

    <name>sniffer</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <packaging>pom</packaging>

    <modules>
        <module>sniffergui</module>
        <module>sniffercollector</module>
        <module>snifferapp</module>
        <module>snifferstats</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.0.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.0.1</version>
        </dependency>
        <dependency>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
                <version>4.12.1</version>
        </dependency>
        <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-launcher</artifactId>
                <version>1.0.1</version>
        </dependency>
        <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-runner</artifactId>
                <version>1.0.1</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>PRISE_gruppe_5_releases</id>
            <name>sniffer_releases</name>
            <url>http://prise-runner.aot.tu-berlin.de:8081/repository/PRISE_gruppe_5_releases/</url>
        </repository>
        <repository>
            <id>PRISE_gruppe_5_snapshots</id>
            <name>sniffer_snapshots</name>
            <url>http://prise-runner.aot.tu-berlin.de:8081/repository/PRISE_gruppe_5_snapshots/</url>
        </repository>
    </repositories>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.github.spotbugs</groupId>
                    <artifactId>spotbugs-maven-plugin</artifactId>
                    <version>3.1.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <effort>Max</effort>
                        <threshold>Low</threshold>
                        <xmlOutput>true</xmlOutput>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-pmd-plugin</artifactId>
                    <version>3.8</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.0</version>
                    <executions>
                        <execution>
                            <id>pre-unit-test</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                                <propertyName>surefireArgLine</propertyName>
                            </configuration>
                        </execution>
                        <execution>
                            <id>post-unit-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
                                <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.19.1</version>
                    <configuration>
                        <argLine>${surefireArgLine}</argLine>
                        <skipTests>${skip.unit.tests}</skipTests>
                        <excludes>
                            <exclude>**/IT*.java</exclude>
                        </excludes>
                    </configuration>
                        <dependencies>
                             <dependency>
                                <groupId>org.junit.platform</groupId>
                                <artifactId>junit-platform-surefire-provider</artifactId>
                                <version>1.0.1</version>
                             </dependency>
                             <dependency>
                                <groupId>org.junit.jupiter</groupId>
                                    <artifactId>junit-jupiter-engine</artifactId>
                                <version>5.0.1</version>
                             </dependency>
                        </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.15</version>
                    <executions>
                        <execution>
                            <id>integration-tests</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                            <configuration>
                                <argLine>${failsafeArgLine}</argLine>
                                <skipTests>${skip.integration.tests}</skipTests>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <distributionManagement>
        <repository>
            <id>***_releases</id>
            <name>sniffer_releases</name>
            <url>*****</url>
        </repository>
        <snapshotRepository>
            <id>***_snapshots</id>
            <name>sniffer_snapshots</name>
            <url>*****</url>
        </snapshotRepository>
    </distributionManagement>
</project>

3 个答案:

答案 0 :(得分:2)

正如奥列格(Oleg)在评论中所说,set MAVEN_OPTS=-Xss10M似乎可以解决此问题。必须每隔一段时间调用一次,但是没关系。所有其他选项都无法解决我的问题。

答案 1 :(得分:0)

您是否通过mvn选项(多线程)运行-T

您描述的内容听起来像是这个问题: https://issues.apache.org/jira/browse/MNG-6382

尝试升级到maven 3.5.3,看看它是否可以解决您的问题。上述错误的修复程序位于3.5.3

答案 2 :(得分:0)

我发现除了Olegs解决方案(对我也适用)之外,还有另一种方法可以避免此错误:

只需将输出管道到文件中,构建便会成功:

mvn clean install > build.log