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

今天使用SpringBoot整合Mybatis時遇到一個錯誤。

***************************
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.

解決方案:
一:使用@Mapper

@Mapper
public interface UserMapper {

    public User getUserById(Integer uId);
}

二、使用@MapperScan(value=”“)


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

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章