dao项目里是可以的,dao.jar被别的项目引用,就扫描不到
日志如下:
main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.zhangjian.cache]' package. Please check your configuration.
application.yml
spring:
datasource:
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://192.168.56.4:3306/mytest
username: test
password: test
driver-class-name: com.mysql.jdbc.Driver
# schema: classpath:import.sql
mybatis:
mapper-locations: classpath*:database/mappers/*.xml
type-aliases-package: com.zhangjian.entity
# config-location: classpath:database/mybatis-config.xml
# typeHandlersPackage:
# check-config-location:
# executorType:
#logging:
# level:
# root: WARN
# com.zhangjian.dao: TRACE
DemoDao.java:
package com.zhangjian.dao;
import com.zhangjian.entity.DemoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* Created by zhangjian on 2017/5/21.
*/
@Mapper
public interface DemoDao extends BaseDao<DemoEntity>{
}
demoMapper.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhangjian.dao.DemoDao">
。。。。。
启动类加注解 @MapperScan(basePackages = "com.zhangjian.dao")