Skip to content

快速开始

最快速的开始

  • 引入依赖
xml
<dependency>
    <groupId>cn.edu.tjnu.blaze</groupId>
    <artifactId>blaze-core</artifactId>
    <version>${blzae.version}</version>
</dependency>
  • 设置环境
java
// 示例:创建需要的数据源
Properties properties = new Properties();
properties.load(Thread.currentThread()
    .getContextClassLoader()
    .getResourceAsStream("db.properties"));
DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);

// 设置数据源到默认环境中
Db.env(dataSource);

注意

默认创建的环境是无数据源的,所以必须设置数据源才可以连接数据库使用!

  • 开始使用
java
// 使用 无实体模式 快速查询
List<Row> rowList = Db.table("sys_user")
    .searcher()
    .select("id", "user_name", "age", "birthday")
    .where(c -> c.ge("age", 18))
    .orderByDesc("birthday")
    .list();

Released under the Apache License.