Maven编译巨大的Java文件

时间:2014-02-20 09:03:42

标签: maven compiler-construction

我有一个Java-File,它包含用于测试目的的WSDL-Strings。 该文件有469kb Eclipse编译项目没有问题。 但是当我尝试“mvn clean compile”时,我收到一个错误:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:


The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)

...

        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.265s

我的编译器插件配置如此

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>

我已经尝试过设置

MAVEN_OPTS=-Xmx1024m

在我的windows7中

为什么eclipse可以编译这个文件,但不是吗?

1 个答案:

答案 0 :(得分:2)

你的问题不是Maven而是Java编译器本身。但是即使编译器不会崩溃,你也会非常喜欢使用64 KiB的类文件code_length

我建议将Java源代码拆分为多个源文件。