当前位置:首页 > 编程语言 > 数据库相关 > 正文内容

Springboot使用jfinal的数据库工具

lcpsky1年前 (2023-03-04)数据库相关326

1. maven依赖

   <groupId>com.jfinal</groupId>
   <artifactId>activerecord</artifactId>
   <version>5.0.4</version>
</dependency>

2. 插件配置

public class DbConfig  {
   @Value("${stockJdbcUrl}")
   String jdbcUrl;
   @Value("${spring.datasource.username:root}")
   String user;
   @Value("${spring.datasource.password:123456}")
   String password;

   public DruidPlugin createDruidPlugin() {
       DruidPlugin druidPlugin = new DruidPlugin(jdbcUrl, user, password);
       return druidPlugin;
   }
   @PostConstruct
   public void initActiveRecordPlugin() {
       DruidPlugin druidPlugin = createDruidPlugin();
       ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
       arp.setDevMode(true);
       arp.setShowSql(true);
       // 先启动 druidPlugin,后启动 arp
       druidPlugin.start();
       arp.start();
   }

}

3. 查询数据

Record t5fMaxRec = Db.findFirst("select max(dttime) dttime from trade5f");



扫描二维码推送至手机访问。

版权声明:本文由软件技术记录发布,如需转载请注明出处。

本文链接:https://lcpsky.top/?id=39

分享给朋友:
返回列表

上一篇:Springboot启动初始化数据执行sql脚本

没有最新的文章了...

“Springboot使用jfinal的数据库工具” 的相关文章

MySQL建立索引原则

建立索引原则1.选择唯一索引。创建主键的时候自动给主键添加了索引,且该索引为唯一性索引。主键一定是唯一性索引。但是一张表中可以有多个唯一性索引,所以唯一性索引不一定是主键。CREATE UNIQUE INDEX uni_user_name ON us...

MySQL8安装记录

MySQL8安装记录

配置文件my.ini[mysqld] # 设置3306端口 port=3307 # 设置mysql的安装目录 basedir=F:\\mysql-8.0.20 # 设置mysql数据库的数据的存放目录 datadir=F:\\mysql-8.0.20\\Da...

Springboot启动初始化数据执行sql脚本

Springboot启动初始化数据执行sql脚本

方法一:配置application.yml文件纯配置。最方便简洁,是最优选择。yml文件: spring:datasource:     schema: classpath:schema.sqldata: classpath:data.sql ini...