FluentMybatis 项目构建、代码生成(一) | FluentMybatis实践(2)

简介: FluentMybatis 项目构建、代码生成(一) | FluentMybatis实践

简述

偶然看到一篇关于阿里新orm框架的文章,好奇的点了进去。开发后端多年,看到这个还是有点兴奋的。常用mysql的orm框架mybatis、jpa,到后来的优化框架mybatis-plus都是用过,他们或多或少都有优缺点吧。程序员本就是日常革新技术的职业,所以了解更多的框架绝对不会有错误。所以我尝试着把自己学习该框架的过程,记录下来,尽可能去掉一些项目工程中用不到的功能,展示一些实用有帮助的代码。



特性

首先分享一下码云上的项目链接:码云地址

看一下官方给出的特性图


image.png

给出对几个特性乍一看还是很全面的,其中比较吸引我的是两点。


1、从图中给出的语法,和sql十分相近,不仔细看还以为是直接sql语句扔了上来。看上去就比较实用。


2、No xml&mapper,虽然mybatis-plus已经做到实用 IService接口实现大部分的sql操作


项目搭建

springboot搭建一项目的过程就不过多赘述了,这里说下我实用的springboot版本


 

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

代码结构如下:


image.png

maven依赖引入-fluent-mybatis


<properties>
    <fluent-mybatis.version>1.8.7</fluent-mybatis.version>
</properties>
<dependencies>
    <!-- 引入fluent-mybatis 运行依赖包, scope为compile -->
    <dependency>
        <groupId>com.github.atool</groupId>
        <artifactId>fluent-mybatis</artifactId>
        <version>${fluent-mybatis.version}</version>
    </dependency>
    <!-- 引入fluent-mybatis-processor, scope设置为provider 编译需要,运行时不需要 -->
    <dependency>
        <groupId>com.github.atool</groupId>
        <artifactId>fluent-mybatis-processor</artifactId>
        <scope>provided</scope>
        <version>${fluent-mybatis.version}</version>
    </dependency>
</dependencies>

完整maven依赖如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.hy</groupId>
    <artifactId>fluent-mybatis-project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>fluent-mybatis-project</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
        <fluent-mybatis.version>1.8.7</fluent-mybatis.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org</groupId>
            <artifactId>jaudiotagger</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>30.1.1-jre</version>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.5.2</version>
        </dependency>
        <!-- 引入fluent-mybatis 运行依赖包, scope为compile -->
        <dependency>
            <groupId>com.github.atool</groupId>
            <artifactId>fluent-mybatis</artifactId>
            <version>${fluent-mybatis.version}</version>
        </dependency>
        <!-- 引入fluent-mybatis-processor, scope设置为provider 编译需要,运行时不需要 -->
        <dependency>
            <groupId>com.github.atool</groupId>
            <artifactId>fluent-mybatis-processor</artifactId>
            <scope>provided</scope>
            <version>${fluent-mybatis.version}</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
相关文章
|
1天前
|
数据库 开发者
EasyCode 自动生成代码
【10月更文挑战第16天】总的来说,EasyCode 自动生成代码是一款非常有价值的工具。它为开发者们带来了便捷、高效和创新,让软件开发变得更加轻松和有趣。随着技术的不断进步,相信 EasyCode 还会不断完善和发展,为开发者们提供更多更好的服务。
6 1
|
5月前
|
XML Java 数据库连接
代码生成插件easycode
代码生成插件easycode
|
5月前
|
SQL Java 数据库连接
JAVAEE框架技术之9-myBatis高级查询技术文档
JAVAEE框架技术之9-myBatis高级查询技术文档
113 0
JAVAEE框架技术之9-myBatis高级查询技术文档
|
前端开发 Java 关系型数据库
EasyCode和Lombok插件的使用,一键生成所需代码(两大代码神器)
📒 程序员小王的博客:程序员小王的博客 🎉 欢迎点赞 👍 收藏 ⭐留言 📝 😊 如有编辑错误联系作者,如果有比较好的文章欢迎分享给我,我会取其精华去其糟粕 🍅java自学的学习路线:java自学的学习路线
432 0
EasyCode和Lombok插件的使用,一键生成所需代码(两大代码神器)
【SSM框架】Mybatis详解04(源码自取),构建完整项目并且测试框架
我们已经学会用Maven快速构建管理项目了,这篇文章就正式构建一个完整的项目。 通过这个案例可以复习maven的使用,自行创建项目,使用MyBatis框架并进行测试。
【SSM框架】Mybatis详解04(源码自取),构建完整项目并且测试框架
|
SQL Java Maven
FluentMybatis 项目构建、代码生成(一) | FluentMybatis实践(1)
FluentMybatis 项目构建、代码生成(一) | FluentMybatis实践
FluentMybatis 项目构建、代码生成(一) | FluentMybatis实践(1)
|
druid 关系型数据库 MySQL
FluentMybatis 项目构建、代码生成(二) | FluentMybatis实践
FluentMybatis 项目构建、代码生成(二) | FluentMybatis实践
FluentMybatis 项目构建、代码生成(二) | FluentMybatis实践
FluentMybatis Where语法(一) | FluentMybatis实践(3)
FluentMybatis Where语法(一) | FluentMybatis实践
FluentMybatis Where语法(一) | FluentMybatis实践(3)
FluentMybatis Where语法(一) | FluentMybatis实践(2)
FluentMybatis Where语法(一) | FluentMybatis实践
FluentMybatis Where语法(一) | FluentMybatis实践(2)