Compare commits
3 Commits
9a916030c3
...
ddf92dc84e
Author | SHA1 | Date |
---|---|---|
zyq | ddf92dc84e | |
zyq | 861f25f90d | |
zyq | d4d125f471 |
|
@ -1,9 +1,14 @@
|
|||
package com.cyx.config;
|
||||
|
||||
import com.alibaba.druid.filter.stat.StatFilter;
|
||||
import com.cyx.db.Jdbc;
|
||||
import com.jfinal.config.JFinalConfig;
|
||||
import com.jfinal.config.*;
|
||||
import com.jfinal.kit.PropKit;
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.jfinal.plugin.activerecord.dialect.AnsiSqlDialect;
|
||||
import com.jfinal.plugin.cron4j.Cron4jPlugin;
|
||||
import com.jfinal.plugin.druid.DruidPlugin;
|
||||
import com.jfinal.template.Engine;
|
||||
/**
|
||||
* @Author Created by cyx.zhang Administrator on 2024/3/1 16:11 周五
|
||||
|
@ -26,6 +31,19 @@ public class AppConfig extends JFinalConfig {
|
|||
*/
|
||||
@Override
|
||||
public void configPlugin(Plugins plugins) {
|
||||
//配置Druid数据库连接池插件
|
||||
DruidPlugin druidPlugin = Jdbc.createDruidPlugin();
|
||||
//配置Druid数据库连接池大小
|
||||
druidPlugin.set(20, 20, 100);
|
||||
//添加 StatFilter 才会有统计数据
|
||||
druidPlugin.addFilter(new StatFilter());
|
||||
plugins.add(druidPlugin);
|
||||
|
||||
//配置ActiveRecord插件
|
||||
ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
|
||||
plugins.add(arp);
|
||||
arp.setDialect(new AnsiSqlDialect());
|
||||
|
||||
//配置任务调度插件
|
||||
Cron4jPlugin cp = new Cron4jPlugin(PropKit.use("cron4j.properties"),"cron4j");
|
||||
plugins.add(cp);
|
||||
|
|
|
@ -22,13 +22,7 @@ public class MyTask implements Runnable{
|
|||
@Override
|
||||
public void run() {
|
||||
EventLog.info("......任务调度开始执行......");
|
||||
String is = Jdbc.jdbc();
|
||||
if ("1".equals(is)) {
|
||||
EventLog.info("......数据库连接成功......");
|
||||
doStart();
|
||||
}else {
|
||||
EventLog.info("......数据库连接失败......");
|
||||
}
|
||||
doStart();
|
||||
EventLog.info("......任务调度结束执行......");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@ public class Jdbc {
|
|||
*/
|
||||
private static Prop p = PropKit.use("config.properties");
|
||||
|
||||
/**
|
||||
* 配置Druid数据库连接池插件
|
||||
* @return
|
||||
*/
|
||||
public static DruidPlugin createDruidPlugin() {
|
||||
DruidPlugin druidPlugin = null;
|
||||
try {
|
||||
|
|
|
@ -9,6 +9,10 @@ import com.jfinal.server.undertow.UndertowServer;
|
|||
*/
|
||||
public class Main {
|
||||
|
||||
/**
|
||||
* 主方法
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
UndertowServer.start(AppConfig.class, 8099, true);
|
||||
EventLog.info("启动成功");
|
||||
|
|
Loading…
Reference in New Issue