国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

springboot 整合fluent mybatis的過程,看這篇夠了

瀏覽:122日期:2023-02-19 11:16:21

1.導入pom依賴

<!--mybatis--><dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version></dependency> <!--mysql依賴--><dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId></dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-dbcp2</artifactId> <version>2.5.0</version></dependency><!-- 引入fluent-mybatis 運行依賴包, scope為compile --><dependency> <groupId>com.github.atool</groupId> <artifactId>fluent-mybatis</artifactId> <version>1.6.8</version></dependency><!-- 引入fluent-mybatis-processor, scope設置為provider 編譯需要,運行時不需要 --><dependency> <groupId>com.github.atool</groupId> <artifactId>fluent-mybatis-processor</artifactId> <version>1.6.8</version></dependency>

2.配置數據庫連接

spring.datasource.url= jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTCspring.datasource.username=rootspring.datasource.password=root

3.創(chuàng)建數據庫表

CREATE TABLE `student` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(20) DEFAULT NULL, `age` int(11) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=’學生表’;

4.創(chuàng)建Student實體類,

①實體類添加 @FluentMybatis

②實現 IEntity 接口

@FluentMybatis@Data@NoArgsConstructorpublic class Student implements IEntity { private Long id; private String name; private Integer age;}

5.重新構建項目

springboot 整合fluent mybatis的過程,看這篇夠了

構建完成后,target目錄下就會新建幾個文件夾

springboot 整合fluent mybatis的過程,看這篇夠了

6. 測試

@Autowired private StudentMapper studentMapper; // target目錄下 @RequestMapping('insert') public void insert(){Student student = new Student();student.setName('dl');student.setAge(25);studentMapper.insert(student); }

數據庫已插入

springboot 整合fluent mybatis的過程,看這篇夠了

************************************

如果出現Mapper文件找不到路徑的異常,很可能是在之前idea中將target文件隱藏了,只需

File --> setting --> File Types 將忽視的target文件刪掉就可以了

springboot 整合fluent mybatis的過程,看這篇夠了

到此這篇關于springboot 整合fluent mybatis的過程,看這篇夠了的文章就介紹到這了,更多相關springboot 整合fluent mybatis內容請搜索好吧啦網以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
主站蜘蛛池模板: 青铜峡市| 阜阳市| 出国| 密云县| 定边县| 太白县| 灌云县| 白河县| 湘乡市| 巴林左旗| 玉龙| 巴马| 镇赉县| 遂川县| 个旧市| 永胜县| 芷江| 新安县| 嘉善县| 湛江市| 抚州市| 林口县| 巫山县| 儋州市| 兴和县| 北流市| 烟台市| 丰原市| 保靖县| 蓬溪县| 读书| 无锡市| 新干县| 宁波市| 桑植县| 衡南县| 宁远县| 股票| 固始县| 泗洪县| 科尔|