国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|編程技術(shù)|正則表達(dá)式|

服務(wù)器之家 - 編程語言 - JAVA教程 - 詳解在SpringBoot應(yīng)用中獲取應(yīng)用上下文方法

詳解在SpringBoot應(yīng)用中獲取應(yīng)用上下文方法

2020-09-20 14:26weiliu007 JAVA教程

本篇文章主要介紹了詳解在SpringBoot應(yīng)用中獲取應(yīng)用上下文方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。

1、定義上下文工具類:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.alimama.config;
 
import org.springframework.context.ApplicationContext;
/**
 * 上下文獲取工具類
 * @author mengfeiyang
 *
 */
public class SpringContextUtil {
 private static ApplicationContext applicationContext;
 
 public static void setApplicationContext(ApplicationContext context) {
  applicationContext = context;
 }
 
 public static Object getBean(String beanId) {
  return applicationContext.getBean(beanId);
 }
}

2、在啟動(dòng)入口類中注入applicationContext

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.alimama;
 
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
 
import com.alimama.config.SbootConfig;
import com.alimama.config.SpringContextUtil;
import com.alimama.config.ZKConfig;
import com.alimama.quartz.InitTask;
 
/**
 * spring boot啟動(dòng)入口類
 * @author mengfeiyang
 *
 */
@ComponentScan
@SpringBootApplication
@EnableConfigurationProperties({ZKConfig.class,SbootConfig.class})
public class SbootApplication implements EmbeddedServletContainerCustomizer{
 
 public static void main(String[] args) {
 ApplicationContext applicationContext = SpringApplication.run(SbootApplication.class, args);
 SpringContextUtil.setApplicationContext(applicationContext);
 }
 
 @Override
 public void customize(ConfigurableEmbeddedServletContainer container) {
 
 }
}

3、調(diào)用方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.alimama.quartz;
 
import java.io.IOException;
 
import org.phoenix.api.action.IInterfaceAPI;
import org.phoenix.api.action.InterfaceAPI;
import org.quartz.Job;
import org.springframework.beans.factory.annotation.Autowired;
 
import com.alimama.config.SpringContextUtil;
import com.alimama.dto.TaskBean;
import com.alimama.service.IConfigService;
import com.alimama.service.impl.ConfigService;
/**
 * 任務(wù)執(zhí)行者
 *
 */
public class TaskHandler implements Job{
 private ConfigService configService = (ConfigService) SpringContextUtil.getBean("configService");
 private IInterfaceAPI interf = new InterfaceAPI();
 @Override
 public void execute(JobExecutionContext arg0){
 String watchDogServer = configService.getwatchDogServer();
  System.out.println(watchDogServer);
 }
}

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://my.oschina.net/u/1266221/blog/888257

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 亚洲第一成av人网站懂色 | 色综合视频 | 国产98色在线 | 日韩 | 午夜精品一区二区三区在线播放 | 君岛美绪一区二区三区 | 欧洲精品视频在线观看 | 久久精品国产v日韩v亚洲 | 日韩有码视频在线 | 亚洲 欧美 日韩在线 | 精品免费一区 | 亚洲精品视频在线观看网站 | 久久久精品网站 | 精品久久久久久久人人人人传媒 | 中文字幕在线免费视频 | 国产一区二区av | 午夜爽爽影院 | 亚洲国产传媒99综合 | 日本久久国产 | 91精品网| 国产精品99久久久久久动医院 | 天天天干天天天操 | 国产黄色av网站 | 九九av| 久操视频在线 | 亚洲免费一区 | www.you日本| 日本中文字幕在线视频 | 亚洲网视频| 91精品久久久久久久久 | 99久久久国产精品 | 久久久久久中文字幕 | 中文日韩在线 | 国产乱码精品一区二区三区中文 | 午夜影院在线播放 | 成人欧美一区二区三区视频xxx | 99久久久久久 | 亚洲国产精品激情在线观看 | av片免费看 | 黄色影视 | 国产日韩精品久久 | 久久久久久久久久国产 |