@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)


 參考網上的博客  敲spring boot 發現一個問題,困擾了半天,在這里記錄下:

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) 的 作用是  :取消數據庫配置。

所以在用到數據庫的時候記得將他改為 @SpringBootApplication , 否則會報錯:如下
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxController': Unsatisfied dependency expressed through field 'xxMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxMapper' defined in file [D:\workspacesidea\pear\target\classes\com\wqq\mapper\xxMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM