Spring boot 财产';sqlSessionFactory';或';sqlSessionTemplate';在使用mybatis的spring boot的spring模拟mvc测试中需要

Spring boot 财产';sqlSessionFactory';或';sqlSessionTemplate';在使用mybatis的spring boot的spring模拟mvc测试中需要,spring-boot,testing,mybatis,spring-mvc-test,Spring Boot,Testing,Mybatis,Spring Mvc Test,演示项目位置 说明: 演示使用Spring-Boot/mybatis-Spring-Boot-starter 1.3.2/mybatis-Spring-Boot-starter-test和其他基本组件 问题: 1、 当我使用SpringMockMVC测试SpringBoot的控制器时,出现如下异常:需要属性'sqlSessionFactory'或'sqlSessionTemplate' 2、 现在我无法测试控制器,但我可以处理mybatis mapper的单元测试 问题解释: 演示可以很好地

演示项目位置

  • 说明: 演示使用Spring-Boot/mybatis-Spring-Boot-starter 1.3.2/mybatis-Spring-Boot-starter-test和其他基本组件

    问题: 1、 当我使用SpringMockMVC测试SpringBoot的控制器时,出现如下异常:需要属性'sqlSessionFactory'或'sqlSessionTemplate' 2、 现在我无法测试控制器,但我可以处理mybatis mapper的单元测试

    问题解释:

  • 演示可以很好地运行
  • 使用mybatis spring启动测试可以处理单元测试 mybatis映射器非常正常
  • 当我测试控制器时,如果我使用@AutoConfigureMybatis 注释,测试可以通过,但无法获得正确的数据 来自DB。映射程序的查询结果为空。我想 @AutoConfigureMatis模拟真实映射器的操作
  • 现在退出系列问题,这是如果服务使用映射器的 结果为了处理某些内容,我无法正确地测试服务
  • 那么,如果有人能帮我解决这个问题呢?我已经在谷歌搜索了两天多,但没有找到解决办法

    一些代码:

    控制器代码


    问题已经解决了。 使用@Import(testserviceinpl.class)可以操作真实的数据库。

    欢迎来到StackoverFlow。请阅读并了解。您遇到的问题与中描述的相同。控制器的测试不应具有
    mybatist
    自动配置的mybatist
    。控制器(服务)的所有依赖项都应该模拟。与我不同。我的问题已经解决了。非常感谢你。
    package com.wqk.mockmvctestofspringbootwithmybatismapper.controller;
    
    import com.wqk.mockmvctestofspringbootwithmybatismapper.dto.CdnNation;
    import com.wqk.mockmvctestofspringbootwithmybatismapper.service.TestService;
    import io.swagger.annotations.Api;
    import io.swagger.annotations.ApiImplicitParam;
    import io.swagger.annotations.ApiImplicitParams;
    import io.swagger.annotations.ApiOperation;
    import io.swagger.annotations.ApiResponses;
    import java.util.List;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    @Api(value = "AbilityOpenController", description = "xxxAPI")
    public class TestController {
    
    
      private final TestService testService;
    
      public TestController(TestService testService) {
        this.testService = testService;
      }
      @GetMapping("/test/spring/mock/mvc/test/with/mybatis/mapper/v{version}")
      @ApiOperation(value = "xx[已经实现]", notes = "xxx", httpMethod = "GET")
      @ApiImplicitParams({
          @ApiImplicitParam(name = "version", value = "版本号,例:1", required = true, paramType = "path", dataType = "String"),
          @ApiImplicitParam(name = "year", value = "年,例:2018", required = true, paramType = "query", dataType = "String"),
          @ApiImplicitParam(name = "month", value = "月,例:1", required = true, paramType = "query", dataType = "String"),
      })
      @ApiResponses({
          //@ApiResponse(code = 500, message = "内部服务异常,请联系管理员")
      })
         public List<CdnNation> getCdnNationParams(
          @PathVariable(value = "version") String version, 
     @RequestParam("year") String year,
          @RequestParam("month") String month) {
            switch (version) {
              case "1":
                return testService.getCdnNationParams(year, month);
              default:
                return testService.getCdnNationParams(year, month);
           }
      }
    }
    
        package com.wqk.mockmvctestofspringbootwithmybatismapper.controller;
        import static org.mockito.Mockito.when;
        import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
        import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
        import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
    
        import com.wqk.mockmvctestofspringbootwithmybatismapper.dto.CdnNation;
        import com.wqk.mockmvctestofspringbootwithmybatismapper.mapper.TestMapper;
        import com.wqk.mockmvctestofspringbootwithmybatismapper.service.TestService;
        import java.util.ArrayList;
        import java.util.List;
        import org.junit.Test;
        import org.junit.runner.RunWith;
        import org.mybatis.spring.boot.test.autoconfigure.AutoConfigureMybatis;
        import org.mybatis.spring.boot.test.autoconfigure.MybatisTest;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
        import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
        import org.springframework.boot.test.mock.mockito.MockBean;
        import org.springframework.http.MediaType;
        import org.springframework.mock.web.MockHttpServletResponse;
    
    
        import org.springframework.test.context.junit4.SpringRunner;
        import org.springframework.test.web.servlet.MockMvc;
    
        @RunWith(SpringRunner.class)
        //@MybatisTest
        //@AutoConfigureMybatis
        @WebMvcTest(TestController.class)
        public class TestControllerTest {
    
          @Autowired
          private MockMvc mockMvc;
    
          @MockBean
          private TestService testService;
          //通过MockBean来mock Mapper,这样可以通过测试,但是失去了真实的Mapper文件读取数据库的能力。无法对service层的实现逻辑进行单元测试。
         //@MockBean
         //private TestMapper testMapper;
         //使用@AutoConfigureMybatis也可以通过测试,但是无法获取真正的Mapper操作获取的数据。
         //@AutoConfigureMybatis
    
    
          @Test
          public void getCdnNationParams() throws Exception {
          List<CdnNation> serviceResults = new ArrayList<>();
        /*serviceResults.add(
            CdnNation.builder().year("2018").month("2").bandWidthMean("24.33").bandWidthPeak("33.33")
                .totalDomainNums("44").totalServeProvinces("76").build());*/
        when(testService.getCdnNationParams("2018", "2")).thenReturn(serviceResults);
    
        MockHttpServletResponse response = this.mockMvc
            .perform(get("/test/spring/mock/mvc/test/with/mybatis/mapper/v1?year=2018&month=2").accept(MediaType.ALL))
            .andDo(print())
            .andExpect(status().isOk())
            .andReturn()
            .getResponse();
        System.out.println("=====mock test result======");
        System.out.println(response.getContentAsString());
      }
    }
    
     package com.wqk.mockmvctestofspringbootwithmybatismapper.mapper;
    
    import com.wqk.mockmvctestofspringbootwithmybatismapper.dto.CdnNation;
    import java.util.List;
    import java.util.Map;
    import org.apache.ibatis.annotations.Param;
    import org.apache.ibatis.annotations.Result;
    import org.apache.ibatis.annotations.Results;
    import org.apache.ibatis.annotations.SelectProvider;
    import org.apache.ibatis.type.JdbcType;
    import org.springframework.stereotype.Repository;
    
    @Repository
    public interface TestMapper {
    
      /**
       * @see TestMapperProvider#selectCdnNationAllIndicators(Map)
       * @param year
       * @param month
       * @return
       */
      @Results(value = {
          @Result(property = "year", column = "year", javaType = String.class, jdbcType = JdbcType.INTEGER),
          @Result(property = "month", column = "month", javaType = String.class, jdbcType = JdbcType.INTEGER),
          @Result(property = "bandWidthPeak", column = "bandwidth_peak", javaType = String.class, jdbcType = JdbcType.DOUBLE),
          @Result(property = "bandWidthMean", column = "bandwidth_mean", javaType = String.class, jdbcType = JdbcType.DOUBLE),
          @Result(property = "totalServeProvinces", column = "total_serve_provinces", javaType = String.class, jdbcType = JdbcType.DOUBLE),
          @Result(property = "totalDomainNums", column = "total_domain_nums", javaType = String.class, jdbcType = JdbcType.DOUBLE),
      })
      @SelectProvider(type = TestMapperProvider.class, method = "selectCdnNationAllIndicators")
      List<CdnNation> selectCdnNationAllIndicators(@Param("year") String year,
          @Param("month") String month);
    }
    
       package com.wqk.mockmvctestofspringbootwithmybatismapper.mapper;
    
    import java.util.Map;
    import org.apache.ibatis.jdbc.SQL;
    
    public class TestMapperProvider {
    
    
      private final static String TABLE_NAME = "komect_data_product_abilityopen_cdnnation";
    
      public String selectCdnNationAllIndicators(Map<String, Object> parameters) {
        return new SQL() {
          {
            SELECT(
                "year,month,bandwidth_peak,bandwidth_mean,total_serve_provinces,total_domain_nums");
            FROM(TABLE_NAME);
            WHERE("(month <= #{month} and year = #{year}) or (year < #{year})");
            ORDER_BY("year desc ,month desc");
          }
        }.toString();
      }
    }
    
    package com.wqk.mockmvctestofspringbootwithmybatismapper.service;
    
    import com.wqk.mockmvctestofspringbootwithmybatismapper.dto.CdnNation;
    import com.wqk.mockmvctestofspringbootwithmybatismapper.mapper.TestMapper;
    import java.util.ArrayList;
    import java.util.List;
    import org.springframework.stereotype.Service;
    
    @Service
    public class TestServiceImpl implements TestService{
    
      private final TestMapper testMapper;
    
      public TestServiceImpl(TestMapper testMapper){
        this.testMapper = testMapper;
      }
    
      @Override
      public List<CdnNation> getCdnNationParams(String year, String month) {
        List<CdnNation> queryResult = testMapper.selectCdnNationAllIndicators(year,month);
        if(queryResult == null){
          queryResult = new ArrayList<>();
        }
        return queryResult;
      }
    }
    
    2018-04-12 16:53:06.436 ERROR 13264 --- [           main] o.s.boot.SpringApplication               : Application run failed
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testMapper' defined in file [/home/sossos/Projects/mockmvctest-ofspringboot-withmybatismapper/target/classes/com/wqk/mockmvctestofspringbootwithmybatismapper/mapper/TestMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:741) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138) [spring-boot-test-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.postProcessFields(MockitoTestExecutionListener.java:99) [spring-boot-test-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.injectFields(MockitoTestExecutionListener.java:79) [spring-boot-test-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.prepareTestInstance(MockitoTestExecutionListener.java:54) [spring-boot-test-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137) [junit-4.12.jar:4.12]
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) [junit-rt.jar:na]
    Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.util.Assert.notNull(Assert.java:193) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:74) ~[mybatis-spring-1.3.2.jar:1.3.2]
    at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73) ~[mybatis-spring-1.3.2.jar:1.3.2]
    at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44) ~[spring-tx-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    ... 40 common frames omitted
    
    2018-04-12 16:53:06.437 ERROR 13264 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@470f1802] to prepare test instance [com.wqk.mockmvctestofspringbootwithmybatismapper.controller.TestControllerTest@7159139f]
    java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.postProcessFields(MockitoTestExecutionListener.java:99) ~[spring-boot-test-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.injectFields(MockitoTestExecutionListener.java:79) ~[spring-boot-test-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.prepareTestInstance(MockitoTestExecutionListener.java:54) ~[spring-boot-test-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137) [junit-4.12.jar:4.12]
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) [junit-rt.jar:na]
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testMapper' defined in file [/home/sossos/Projects/mockmvctest-ofspringboot-withmybatismapper/target/classes/com/wqk/mockmvctestofspringbootwithmybatismapper/mapper/TestMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:741) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138) ~[spring-boot-test-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    ... 25 common frames omitted
    Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.util.Assert.notNull(Assert.java:193) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:74) ~[mybatis-spring-1.3.2.jar:1.3.2]
    at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73) ~[mybatis-spring-1.3.2.jar:1.3.2]
    at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44) ~[spring-tx-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    ... 40 common frames omitted