简体   繁体   English

在Maven中使用FindSecBugs会引发java.lang.OutOfMemoryError

[英]Using FindSecBugs in Maven throws java.lang.OutOfMemoryError

I'm new to Maven.I'm using Mac OSX . 我是Maven的新手,正在使用Mac OSX I tried to build the project using maven and it happened properly. 我试图使用Maven来构建项目,但它发生得很好。 Then I used mvn spotbugs:spotbugs to use the spotbugs plugin! 然后我使用了mvn spotbugs:spotbugs来使用spotbugs插件! It took a while and threw Exception in thread "main" 花了一段时间,在线程“ main”中引发了异常

java.lang.OutOfMemoryError: Java heap space. java.lang.OutOfMemoryError:Java堆空间。

The project I tried is 330 MB which is quite big and I can do nothing about it for now.I tried many solutions online: 我尝试的项目是330 MB,这是一个很大的项目,目前我对此无能为力,我在网上尝试了许多解决方案:

1.export MAVEN_OPTS="-Xmx2048m" (I tried increasing upto 12000m still wasn't working) 1.export MAVEN_OPTS="-Xmx2048m" (我尝试增加到12000m仍然无法正常工作)

2.Used this plugin 2.使用这个插件

       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
            <fork>true</fork>
            <meminitial>1024m</meminitial>
            <maxmem>8096m</maxmem>
        </configuration>
       </plugin>

and still didn't work. 仍然没有用。

Can anybody guide me through it? 有人可以指导我完成它吗? I'm using maven spotbugs version 3.1.12. 我正在使用Maven Spotbugs版本3.1.12。

Using java 11,Maven 3 使用Java 11,Maven 3

The SpotBugs Maven Plugin has " How do I avoid OutOfMemory errors? " in its FAQ which I assume you have seen (since you tried MAVEN_OPTS="-Xmx2048m" ) SpotBugs Maven插件在其常见问题解答中具有“ 我如何避免OutOfMemory错误?假定您尝试了MAVEN_OPTS="-Xmx2048m"

But there is one more thing there 但是那里还有一件事

You can also use the fork option which will for a new JVM. 您也可以使用fork选项,该选项将用于新的JVM。 You then use the maxHeap option to control the heap size. 然后,您可以使用maxHeap选项控制堆大小。

Looking at the docs is seams in 3.1.12.3-SNAPSHOT the fork option is true by default. 文档3.1.12.3-SNAPSHOT的接缝,默认情况下fork选项为true If that is the case for 3.1.12 (or whatever is the exact version you use) and if I'm reading the docs correctly, then you have to configure the maxHeap which defaults to 512 . 如果是3.1.12 (或您使用的确切版本),并且我在正确阅读文档,则必须配置默认为512maxHeap

as mentioned above, try adjusting the maxHeap value. 如上所述,请尝试调整maxHeap值。

what follows is a snippet of maven configuration. 以下是Maven配置的摘要。 this was how i configured spotbugs in order to avoid the out of memory error. 这就是我配置Spotbug的方式,以避免内存不足错误。

 <reporting>
    <plugins>
        <plugin>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs-maven-plugin</artifactId>
            <version>${spotbugs-maven-plugin.version}</version>
            <configuration>
                <effort>Max</effort>
                <threshold>Low</threshold>
                <maxHeap>2048</maxHeap>
            </configuration>
        </plugin>
    </plugins>
</reporting>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM