Commit 1ac2432b by huangfusuper

改变数据源DataSource的注入方式

parent de01da4a
package com.byit.conf;
import lombok.Data;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.sql.DataSource;
/**
* @program: byit-myth-job->DataSourceConf
* @description: TODO
* @author: huangfu
* @date: 2019/12/9 19:52
**/
@Data
@Component("dataSourceConf")
public class DataSourceConf {
@Resource
private DataSource dataSource;
}
package com.byit.conf;
import com.byit.thread.JobFlowThread;
import com.byit.thread.JobScheduleHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.sql.DataSource;
/**
* @program: byit-myth-job->MythJobScheduler
......@@ -19,12 +16,11 @@ import javax.sql.DataSource;
**/
@Component
@Slf4j
@DependsOn("dataSourceConf")
public class MythJobScheduler implements InitializingBean, DisposableBean {
@Autowired
DataSourceConf dataSourceConf;
@Autowired
private JobScheduleHelper jobScheduleHelper;
@Autowired
private JobFlowThread jobFlowThread;
/**
* 销毁方法
* @throws Exception
......@@ -40,8 +36,10 @@ public class MythJobScheduler implements InitializingBean, DisposableBean {
*/
@Override
public void afterPropertiesSet() throws Exception {
jobScheduleHelper.setDataSource(dataSourceConf.getDataSource());
//启用扫描线程
jobScheduleHelper.start();
jobFlowThread.start();
}
}
package com.byit.thread;
import com.byit.service.FlowVersionService;
import com.byit.service.MythJobFlowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
/**
* @program: byit-myth-job->JobFlowThread
* @description: 扫描任务流表,关联版本表 获取任务流信息!
* 将此工作流添加到执行记录表!将该工作流下的该版本所有节点添加到预读表!
* @author: huangfu
* @date: 2019/12/18 14:12
**/
@Slf4j
@Component
public class JobFlowThread {
private DataSource dataSource;
@Autowired
private MythJobFlowService mythJobFlowService;
@Autowired
private FlowVersionService flowVersionService;
@Autowired
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
public void start(){
System.out.println(dataSource+"我是扫描工作流的!" );
}
}
......@@ -312,6 +312,7 @@ public class JobScheduleHelper{
scheduleThread.start();
}
@Autowired
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment