mybatis 换 mybatis-plus 后启动异常,sqlSessionFactory OutOfMemoryError: GC overhead limit exceeded

将老项目中的mybatis替换为mybatis-plus后,虽然代码生成器正常工作,但在执行单元测试时遇到启动异常。原本的pom配置下项目可以顺利运行,但更新后频繁出现OutOfMemoryError: GC overhead limit exceeded。尝试按照mybatis-plus官网的快速启动教程配置,甚至在新项目中按步骤操作,均未能解决问题。最终,通过下载并运行mybatis-plus的官方示例项目(基于h2数据库),并在修改为oracle数据库后成功运行。然而,将此示例项目的配置与自己的项目逐一比对,未能找出导致自己项目启动失败的具体原因。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

老项目使用 

    <dependency>
         <groupId>org.mybatis</groupId>
         <artifactId>mybatis</artifactId>
         <version>3.5.5</version>
     </dependency>

替换为 

	<dependency>
	    <groupId>com.baomidou</groupId>
	    <artifactId>mybatis-plus</artifactId>
	    <version>3.4.1</version>
	</dependency>  

已经可以正常使用代码生成器,但是运行之前的单元测试,发现出现异常,

15:15:43.064 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class cn.com.git.batch.service.CheckConfigServiceTest]
15:15:43.076 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
15:15:43.109 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
15:15:43.283 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [cn.com.git.batch.service.CheckConfigServiceTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
15:15:43.359 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [cn.com.git.batch.service.CheckConfigServiceTest], using SpringBootContextLoader
15:15:43.378 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [cn.com.git.batch.service.CheckConfigServiceTest]: class path resource [cn/com/git/batch/service/CheckConfigServiceTest-context.xml] does not exist
15:15:43.380 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [cn.com.git.batch.service.CheckConfigServiceTest]: class path resource [cn/com/git/batch/service/CheckConfigServiceTestContext.groovy] does not exist
15:15:43.381 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [cn.com.git.batch.service.CheckConfigServiceTest]: no resource found for suffixes {-context.xml, Context.groovy}.
15:15:43.384 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [cn.com.git.batch.service.CheckConfigServiceTest]: CheckConfigServiceTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
15:15:43.571 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [cn.com.git.batch.service.CheckConfigServiceTest]
15:15:44.135 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\Users\git\git\batch-springboot\batch-springboot\batch-view\target\classes\cn\com\git\WebApplication.class]
15:15:44.142 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration cn.com.git.WebApplication for test class cn.com.git.batch.service.CheckConfigServiceTest
15:15:44.714 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [cn.com.git.batch.service.CheckConfigServiceTest]: using defaults.
15:15:44.717 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
15:15:44.793 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@59af0466, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3e6ef8ad, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@346d61be, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@55536d9e, org.springframework.test.context.support.DirtiesContextTestExecutionListener@747edf66, org.springframework.test.context.transaction.TransactionalTestExecutionListener@3d1cfad4, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@62230c58, org.springframework.test.context.event.EventPublishingTestExecutionListener@2cd2a21f, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@2e55dd0c, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@74455848, org.sprin
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值