MybatisTest No qualified bean for mapper

40 views
Skip to first unread message

Daniel Cosio

unread,
Dec 1, 2021, 6:51:26 PM12/1/21
to mybatis-user
I'm putting together a small unit test in a spring boot app.
spring-boot: 2.6.1
mybatis-starter:2.2.0
Junit 5: 5.8.0

I've been following the instructions on mybatis-autoconfigure

Im not having any luck getting the test to work. If I add a @SpringBootApplication as noted in the link I provided I get 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type error

If I remove the @SpringBootApplication I get:
Neither @ContextConfiguration nor @ContextHierarchy found for test class [fehrm.servicelayer.mapper.EnqueueStatusDaoTest], using SpringBootContextLoader


Here is my Test class: Im using H2 for the db.. 

@MybatisTest

@ActiveProfiles("test")

@Import(EnqueueStatusDao.class)

public class EnqueueStatusDaoTest {


@Autowired

private EnqueueStatusDao enqueueStatusDao;

@Test

public void testSelect()

{

EnqueueStatus es = enqueueStatusDao.selectEnqueuePatient("1000000050");

Assertions.assertNotNull(es);

}

Kazuki Shimizu

unread,
Dec 11, 2021, 1:00:18 PM12/11/21
to mybatis-user
Could you provide reproduce project?

2021年12月2日木曜日 8:51:26 UTC+9 dcc...@gmail.com:
Reply all
Reply to author
Forward
0 new messages