Consider defining a bean of type ‘com.fh.mapper.UserMapper‘ in your configuration
原创
©著作权归作者所有:来自51CTO博客作者wx6316c4e40e2ec的原创作品,请联系作者获取转载授权,否则将追究法律责任
错误信息:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userMapper in com.fh.service.impl.UserServiceImpl required a bean of type 'com.fh.mapper.UserMapper' that could not be found.
Action:
Consider defining a bean of type 'com.fh.mapper.UserMapper' in your configuration.
Disconnected from the target VM, address: '127.0.0.1:49246', transport: 'socket'
Process finished with exit code 0
错误代码:
package com.cc;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SsmSystemApplication {
public static void main(String[] args) {
SpringApplication.run(SsmSystemApplication.class, args);
}
}
报错原因:没有
解决方案:@MapperScan(basePackages= {“com.xx.mapper”})注解
package com.cc;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan(basePackages= {"com.cc.mapper"})
public class SsmSystemApplication {
public static void main(String[] args) {
SpringApplication.run(SsmSystemApplication.class, args);
}
}