Consider defining a bean of type 'com.xxx.item.mapper.BrandMapper' in your configuration.報錯解決辦法

提示Mapper裏面報錯,那說明是mapper找不到,掃描不到咯。上篇文章那個是Service裏面,很有可能就是@Service註解沒有添加;而現在這個就是mapper找不到

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

Action:

Consider defining a bean of type 'com..item.mapper.BrandMapper' in your configuration.

解決辦法如下:
在啓動類上面添加:@MapperScan(“com.xxx.item.mapper”)註解。()裏面的內容,根據你自己的路徑決定。另外,@MapperScan是在tk.mybatis下面的,注意別導錯包。如下:

@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.ztoshop.item.mapper")//這個是在tk.mybatis下面
public class ZtoItemServiceApplication {

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