SpringBoot:Consider defining a bean of type 'com.wzw.blog.mapper.UserMapper' in your configuration.

I encountered an error today while integrating Mybatis with SpringBoot.

***************************
APPLICATION FAILED TO START
***************************

Description:

Field userMapper in com.wzw.blog.service.impl.UserServiceImpl required a bean of type 'com.wzw.blog.mapper.UserMapper' that could not be found.


Action:

Consider defining a bean of type 'com.wzw.blog.mapper.UserMapper' in your configuration.

Solution:
One: Use @Mapper

@Mapper
public interface UserMapper {

    public User getUserById(Integer uId);
}

2. Use @MapperScan(value="")


@SpringBootApplication
@MapperScan(value="com.wzw.blog.mapper")
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325549396&siteId=291194637