百度了很久,很多人说要么是没有加@Mapper要么是没有加@service。
之前因为报错在@SpringBootApplication注解后面加了一个排除数据源配置的属性,@SpringBootApplication(exclude = DataSourceAutoConfiguration.class),原以为不是这方面的问题,排除了版本冲突等问题等
controller改为:
pom.xml文件也很简单
<parent>
<artifactId>service</artifactId>
<groupId>com.example</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>service_hosp</artifactId>
<name>service-hosp</name>
<description>service-hosp</description>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
</dependencies>
<build>
<finalName>service-hosp</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
借鉴于:
springboot整合mybatis的时候报错Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required - 坚守梦想 - 博客园解决Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required - 牧牛人Alec - 博客园