在学习 springboot 框架时遇到这个问题,首先整合了 springboot 与 mybatis,没有用模板框架,controller 直接返回数据,运行之后服务启动正常,浏览器访问正常,数据显示正常! 然后开始整合模板 thymeleaf 时出现问题了,我先是配置 application.yml 中的 thymeleaf 的相关配置,和 thymeleaf 的 pom 文件依赖,配置信息和依赖如下: #模板类配置 spring: freemarker: cache: false prefix: classpath:/templates/ suffix: .html encoding: UTF-8 content-type: text/html mode: HTML5 <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-thymeleaf</artifactid> </dependency> 然后写好 controller 和模板类,开始运行项目,出现各种异常,详情如下: Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.报出这个异常后,我在启动类注解上加上这个:@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})然后再重新启动,上面这个问题不报了,出现了个新的问题,详情如下:java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required,求解决方案,不胜感激!