81 Star 429 Fork 138

tanghc/fastmybatis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

简介 | Intro

fastmybatis for Solon - 让Solon使用体验更加舒适

更新日志

  • 2.10.0:solon更新到2.6.1
  • 2.9.6:solon更新到2.5.3
  • 2.8.1:solon更新到2.3.7

示例 | Example

server:
  port: 6041

# 配置数据源
dataSource:
  db1:
    # 与数据库名可用保持一致
    schema: stu
    jdbcUrl: jdbc:mysql://localhost:3306/stu?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true
    driverClassName: com.mysql.cj.jdbc.Driver
    username: root
    password: root

mybatis:
  db1:
    mappers:
      - "com.myapp.demo.dao.*"
      # 指定mybatis xml文件存放目录
      - "classpath:mybatis/mapper/*.xml"
    configuration:
      cacheEnabled: false
      mapUnderscoreToCamelCase: true
    globalConfig:
      logicNotDeleteValue: "0"
      disableSqlAnnotation: false
    plugins:
      - sqlFormatterPlugin:
          # 开启
          enable: true
          class: "com.gitee.fastmybatis.core.support.plugin.SqlFormatterPlugin"
          appendDelimiter: true
          delimiter: ";"
          useDruid: false
          format: "====== SQL ======\n%s"


solon.logging.appender:
  console:
    level: INFO

# 记录器级别的配置示例
solon.logging.logger:
  "root": #默认记录器配置
    level: INFO
  "com.zaxxer.hikari":
    level: WARN

注入示例:


@Controller
public class DemoController {

    @Db("db1")
    TUserMapper mapper;

    /**
     * http://localhost:6041/index
     *
     * @return
     */
    @Mapping("index")
    public TUser index() {
        return mapper.getById(6);
    }

    /**
     * http://localhost:6041/index2
     *
     * @return
     */
    @Mapping("index2")
    public List<TUser> index2() {
        Query query = new Query()
                .in("id", Arrays.asList(4, 5, 6));
        return mapper.list(query);
    }
}

完整示例请查看本项目测试用例

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/durcframework/fastmybatis.git
git@gitee.com:durcframework/fastmybatis.git
durcframework
fastmybatis
fastmybatis
master

搜索帮助