天天看點

springboot 啟動mapper報錯 和 @ComponentScan注解的作用

需要在springboot 啟動類上加入@mapperScan("") 注解,括号是mapper的包路徑

@SpringBootApplication
@MapperScan("com.qiyun.test.mapper")
           

@ComponentScan(basePackages = {"com.qiyun"}),加在 springboot 啟動類上即可

@SpringBootApplication
@ComponentScan(basePackages = "com.qiyun")
@MapperScan("com.qiyun.ssosevice.mapper")
public class SsoApplication {
           

// @compontScan 是加載依賴的子產品的@configruation 注解的配置的檔案,例如service-base子產品的 SwaggerConfig類,

// 如果想在service-edu 子產品使用swagger 的話,就必須用@compontScan在edu的啟動類上加上,因為是獨立兩個子產品,

需要使用另一個子產品加載的配置的話,就需要@ComponentScan 來解決了

繼續閱讀