title: springboot+mybatis multi-module project maven
body: <p>Below picture is my project structure.
  <a href="https://i.stack.imgur.com/fRNJn.png" rel="nofollow noreferrer">project structure</a></p>
  <p>parent project is demo-mybatis sub module are mybatis-dao,demo-service.
  demo-mybatis pom.xml below:</p>
     
  <p>
  4.0.0
  pom
  
  mybatis-dao
  demo-service
  demo-mybatis-app
  
  
  org.springframework.boot
  spring-boot-starter-parent
  2.3.2.RELEASE
   
  
  com.example
  demo-mybatis
  0.0.1-SNAPSHOT
  demo-mybatis
  Demo project for Spring Boot</p>
  <pre><code>&lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;optional&gt;true&lt;/optional&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
                  &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
          &lt;artifactId&gt;druid-spring-boot-starter&lt;/artifactId&gt;
          &lt;version&gt;1.1.10&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.mybatis.spring.boot&lt;/groupId&gt;
          &lt;artifactId&gt;mybatis-spring-boot-starter&lt;/artifactId&gt;
          &lt;version&gt;1.3.2&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  mybatis-dao UserMapper.java interface:
  ```
  <pre><code>@Repository
  public interface UserMapper {
      List selectByName(String name);
      int insert(User user);
      void update(User user);
      void delete(Long id);
      User verify(User user);
      List select();
  }
  </code></pre>
  <pre><code>demo-service UserServiceImpl.java class :
  </code></pre>
  <pre><code>@Service
  public class UserServiceImpl implements UserService {
  
      @Resource
      private UserMapper userMapper;
  
      @Override
      public List selectByName(String name) {
          return null;
      }
  
      @Override
      public int insert(User user) {
          return 0;
      }
  }
  </code></pre>
  <pre><code>run application class :
  ``` @SpringBootApplication
  @ComponentScan(basePackages = {&quot;com.example&quot;,&quot;com.wjs&quot;})
  @EnableCaching(proxyTargetClass = true)
  @MapperScan(basePackages = {&quot;com.wjs.model.dao&quot;})
  public class DemoMybatisAppApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(DemoMybatisAppApplication.class, args);
      }
  
  }
  </code></pre>
  <p>application.properties ：</p>
  <pre><code>server.port=8002
  spring.datasource.url=jdbc:mysql://localhost:3306/demo?useSSL=false
  spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  spring.application.name=demo-mybatis
  spring.datasource.username=root
  spring.datasource.password=root
  spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
  mybatis.mapper-locations=classpath:mapper/*.xml
  mybatis.type-aliases-package=com.wjs.model.entity
  </code></pre>
  <p>always exception below :
  I can not find why?
  I try this:</p>
  <pre><code>    @Resource
      private UserMapper userMapper;
  </code></pre>
  <p>question is :</p>
  <pre><code>  nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'userMapper' is expected to be of type 'com.wjs.model.dao.UserMapper' but was actually of type 'com.sun.proxy.$Proxy55'
  </code></pre>
  <p>and</p>
  <pre><code>    @Autowired
      private UserMapper userMapper;
  </code></pre>
  <p>question is :</p>
  <pre><code> No qualifying bean of type 'com.wjs.model.dao.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  </code></pre>
  <p>I'm crazy</p>