错误信息:

***************************
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);
}

}