參考網上的博客 敲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