springBoot整合Quarzt2.3

首先,你要配置好springboot的配置(在resources下)

我把其改为application.yml

 1 # Tomcat
 2 server:
 3   tomcat:
 4     uri-encoding: UTF-8
 5     max-threads: 1000
 6     min-spare-threads: 30
 7   port: 8080
 8   servlet:
 9     context-path: /xiaobo
10 
11 spring:
12   profiles:
13     active: dev
14   datasource:
15     type: com.alibaba.druid.pool.DruidDataSource
16     driver-class-name: com.mysql.jdbc.Driver
17     filters: stat
18     maxActive: 20
19     initialSize: 1
20     maxWait: 60000
21     minIdle: 1
22     timeBetweenEvictionRunsMillis: 60000
23     minEvictableIdleTimeMillis: 300000
24     validationQuery: select 'x'
25     testWhileIdle: true
26     testOnBorrow: false
27     testOnReturn: false
28     poolPreparedStatements: true
29     maxOpenPreparedStatements: 20
30   jackson:
31     date-format: yyyy-MM-dd HH:mm:ss
32     time-zone: GMT+8
33   servlet:
34     multipart:
35       max-file-size: 100MB
36       max-request-size: 100MB
37       enabled: true
38   freemarker:
39     suffix: .html
40     request-context-attribute: request
41 
42 blgg:
43   redis:
44     open: false
45   shiro:
46     redis: false
47 
48 
49 
50 
51 #mybatis
52 mybatis-plus:
53   mapper-locations: classpath:com/blgg/permission/**/**.xml
54   #实体扫描,多个package用逗号或者分号分隔
55   typeAliasesPackage: com.blgg.permission.modules.*.entity
56   global-config:
57     #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
58     id-type: 0
59     #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
60     field-strategy: 2
61     #驼峰下划线转换
62     db-column-underline: true
63     #刷新mapper 调试神器
64     refresh-mapper: true
65     #逻辑删除配置
66     logic-delete-value: -1
67     logic-not-delete-value: 0
68     #自定义填充策略接口实现
69     #meta-object-handler: com.baomidou.springboot.xxx
70     #自定义SQL注入器
71     sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
72   configuration:
73     map-underscore-to-camel-case: true
74     cache-enabled: false
75     call-setters-on-nulls: true
76 
77 
78 
79 logging:
80   config: classpath:logback-spring.xml
application.yml

数据源配置在

spring:
  datasource:
     name: dev
     url: jdbc:mysql://localhost:3306/blgg_permission?useUnicode=true&characterEncoding=utf8
     username: root
     password: root
application-dev.yml

 

 

这里我们先写一个任务类

package com.blgg.permission.modules.job.task;

import com.blgg.permission.modules.sys.entity.User;
import com.blgg.permission.modules.sys.service.UserService;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * ┏┓   ┏┓
 * ┏┛┻━━━┛┻┓
 * ┃       ┃
 * ┃   ━   ┃
 * ┃ ┳┛ ┗┳ ┃
 * ┃       ┃
 * ┃   ┻   ┃
 * ┃       ┃
 * ┗━┓   ┏━┛
 *   ┃   ┃神兽保佑
 *   ┃   ┃代码无BUG!
 *   ┃   ┗━━━┓
 *   ┃       ┣┓
 *   ┃       ┏┛
 *   ┗┓┓┏━┳┓┏┛
 *    ┃┫┫ ┃┫┫
 *    ┗┻┛ ┗┻┛
 *
 *
 * @ClassName TestTask
 * @Description
 * @Author xiaobo
 * @Date 2018/10/16/016 1:18
 */
@Component("testTask")
public class TestTask {
    private Logger logger=LoggerFactory.getLogger(getClass());

    @Autowired
    private UserService userService;

    public void test1(String params){
        logger.info("我是带参数的test方法,正在被执行,参数为:"+params);

        try{
            Thread.sleep(1000L);
        }catch (InterruptedException e){
            e.printStackTrace();
        }

        User user=userService.selectById(1L);
        System.out.println(ToStringBuilder.reflectionToString(user));
    }

    public void test2(){
        logger.info("我是不带参数的test1方法,正在被执行!");
    }


}
TestTask

 

转载于:https://www.cnblogs.com/xiaobo520/p/9801332.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值