Spring Boot 实用MyBatis做数据库操作
时间:2021-07-01 10:21:17
帮助过:79人阅读
本项目基于maven构建,使用mybatis-spring-boot作为spring-boot项目的持久层框架
spring-boot中使用mybatis持久层框架与原spring项目使用方式和注解都不相同,需要依赖mybatis-spring-boot包
1、引入mybatis和数据库及其他项目依赖
1.1、引入mybatis依赖
[html] view plain copy
- <!-- mybatis-spring-boot --> <dependency> <groupId></groupId> <artifactId></artifactId> <version></version> </dependency>
1.2、引入mysql 驱动
[html] view plain copy
- <!-- mysql--> <dependency> <groupId></groupId> <artifactId></artifactId> </dependency>
1.3、项目pom.xml一览
[html] view plain copy
- <project= =
- => <modelVersion></modelVersion> <groupId></groupId> <artifactId></artifactId> <packaging></packaging> <version></version> <name></name> <parent> <groupId></groupId> <artifactId></artifactId> <version></version> </parent> <dependencies>
- <dependency> <groupId></groupId> <artifactId></artifactId> <exclusions><exclusion><groupId></groupId> <artifactId></artifactId></exclusion></exclusions>> </dependency>
- <dependency> <groupId></groupId> <artifactId></artifactId> </dependency>
- <dependency> <groupId></groupId> <artifactId></artifactId> </dependency> <dependency> <groupId></groupId> <artifactId></artifactId> </dependency>
- <dependency> <groupId></groupId> <artifactId></artifactId> </dependency> <dependency> <groupId></groupId> <artifactId></artifactId> <scope></scope> </dependency> <dependency> <groupId></groupId> <artifactId></artifactId> <scope></scope> </dependency>
- <dependency> <groupId></groupId> <artifactId></artifactId> <version></version> </dependency>
- <dependency> <groupId></groupId> <artifactId></artifactId> <version></version> </dependency> <dependency> <groupId></groupId> <artifactId></artifactId> <version></version> </dependency> </dependencies> <profiles> <profile> <id></id> <dependencies> > <dependency> <groupId></groupId> <artifactId></artifactId> <type></type> </dependency> </dependencies> </profile> </profiles>
- <build> <plugins> <plugin> <groupId></groupId> <artifactId></artifactId> </plugin> </plugins> </build> <repositories> <repository> <id></id> <url></url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id></id> <url></url>