spring boot项目添加MyBatis
程序员文章站
2022-04-25 08:24:25
...
添加 pom.xml jar
<!-- MyBatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
<!-- oracle -->
<dependency>
<groupId>org.clojars.zentrope</groupId>
<artifactId>ojdbc</artifactId>
<version>11.2.0.3.0</version>
</dependency>
配置文件添加
mybatis:
mapper-locations: classpath:dao/*.xml
spring:
datasource:
url: jdbc:oracle:thin:@10.20.133.129:1521:gfzsh
username: icf
password: icf
在spring boot启动实体类中添加@MapperScan(“com.dao”)注解
接下来在创建Ctroller层Service层Dao层即可