我有一个 spring-boot 测试,可以启动我的应用程序并对其运行一些测试。
我在设置应用程序堆大小时遇到问题。
当我通过 Maven 和 Surefire 设置内存参数运行它时,一切正常,但尝试从我的 IDE (Intellij) 运行它却不行,并且我得到 java.lang.OutOfMemoryError: Java heap space。
@RunWith(Parameterized.class)
@SpringApplicationConfiguration(classes = MyApplication.class)
@WebAppConfiguration
public class MyTest {
public MyTest(String name, URL url) {
this.url = url;
}
@Parameterized.Parameters...
public static Iterable<Object[]> tests() throws IOException {
....
}
@Before
public void setUpContext() throws Exception {
new TestContextManager(getClass()).prepareTestInstance(this);
}
@Test
public void doSomething() throws Exception {
...
}
}
最佳答案
我明白了。
显然,我的 pom 上的 Surefire 插件定义优先于 intellij 运行配置。
我需要 -Xmx1024 但它是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<argLine>-Xmx256m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
关于java - Spring-boot应用测试-内存问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46942793/