Consider defining a bean of type ‘*Mapper‘ in your configuration.
在使用最新的mybatis-3.5.6时,使用注解@Mapper
修饰相应的mapper接口,但是在controller里不能使用@Autowired
自动注入,报错Consider defining a bean of type '*Mapper' in your configuration.
但是使用mybatis-2.0.0就不会出现这个错误。
经过查找,分析,发现在启动类里添加注解@ComponentScan
,可以解决这个问题,里面的路径是对应的mapper路径
@SpringBootApplication
@ComponentScan({ "com.delivery.mapper"})
public class WebServiceApplication extends SpringBootServletInitializer {
参考
还没有评论,来说两句吧...