当前位置: 首页 > news >正文

武汉高端企业网站建设网址关键词查询网站

武汉高端企业网站建设,网址关键词查询网站,豪华网站建设,哪里网站可以有做那个的女人1.前言 我有一个需求:有四个系统需要处理字段,一开始利用switch-case进行区分编码,后期字段处理越来越多,导致switch-case代码冗余,不太好,然后想通过java单继承多实现的性质进行优化。 2.实现 2.1定义S…

1.前言

我有一个需求:有四个系统需要处理字段,一开始利用switch-case进行区分编码,后期字段处理越来越多,导致switch-case代码冗余,不太好,然后想通过java单继承多实现的性质进行优化。

2.实现

2.1定义Spring boot 上下文环境

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
 
@Component
public class ApplicationContextProvider implements ApplicationContextAware {
 
    /**
     * 上下文对象实例
     */
    private static ApplicationContext applicationContext;
 
    @SuppressWarnings("static-access")
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        ApplicationContextProvider.applicationContext = applicationContext;
    }
 
    /**
     * 获取applicationContext
     *
     * @return
     */
    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }
 
    /**
     * 通过name获取 Bean.
     *
     * @param name
     * @return
     */
    public static Object getBean(String name) {
        return getApplicationContext().getBean(name);
    }
 
    /**
     * 通过class获取Bean.
     *
     * @param clazz
     * @param <T>
     * @return
     */
    public static <T> T getBean(Class<T> clazz) {
        return getApplicationContext().getBean(clazz);
    }
 
    /**
     * 通过name,以及Clazz返回指定的Bean
     *
     * @param name
     * @param clazz
     * @param <T>
     * @return
     */
    public static <T> T getBean(String name, Class<T> clazz) {
        return getApplicationContext().getBean(name, clazz);
    }

}

2.2创建接口

public interface UserService {

        //获取用户的主要任务

        String getTask();

}

2.3多实现

@Service("student")
public class StudentServiceImpl implements UserService {
    @Override
    public String getTask() {
        return "学生在学习";
    }
}


@Service("admin")
public class TeacherServiceImpl implements UserService {
    @Override
    public String getTask() {
        return "管理员在管理";
    }
}

2.4引入上下文,通过接口调用方法

@Resource

private ApplicationContext applicationContext;

UserService userService = applicationContext.getBean("student", UserService );

String task = userService.getTask();


文章转载自:
http://bend.mnqg.cn
http://harelipped.mnqg.cn
http://ownership.mnqg.cn
http://misemploy.mnqg.cn
http://international.mnqg.cn
http://polygonometry.mnqg.cn
http://theocrasy.mnqg.cn
http://acrogen.mnqg.cn
http://mashy.mnqg.cn
http://unworldly.mnqg.cn
http://spec.mnqg.cn
http://pal.mnqg.cn
http://nairnshire.mnqg.cn
http://civism.mnqg.cn
http://riancy.mnqg.cn
http://honeysweet.mnqg.cn
http://absentation.mnqg.cn
http://capillarity.mnqg.cn
http://cinephile.mnqg.cn
http://kittiwake.mnqg.cn
http://chorine.mnqg.cn
http://voracity.mnqg.cn
http://chowmatistic.mnqg.cn
http://wogland.mnqg.cn
http://dobla.mnqg.cn
http://sian.mnqg.cn
http://articulator.mnqg.cn
http://slowup.mnqg.cn
http://follower.mnqg.cn
http://systaltic.mnqg.cn
http://thundering.mnqg.cn
http://consonancy.mnqg.cn
http://pinger.mnqg.cn
http://horsily.mnqg.cn
http://mridang.mnqg.cn
http://make.mnqg.cn
http://ifni.mnqg.cn
http://guzzle.mnqg.cn
http://epicenter.mnqg.cn
http://fibroplasia.mnqg.cn
http://oneself.mnqg.cn
http://chirk.mnqg.cn
http://birdyback.mnqg.cn
http://ruffe.mnqg.cn
http://aquiclude.mnqg.cn
http://surculi.mnqg.cn
http://encephalitis.mnqg.cn
http://domical.mnqg.cn
http://rayah.mnqg.cn
http://kibitka.mnqg.cn
http://delivery.mnqg.cn
http://heterotopia.mnqg.cn
http://use.mnqg.cn
http://wattage.mnqg.cn
http://precautious.mnqg.cn
http://manatee.mnqg.cn
http://nam.mnqg.cn
http://homoeothermic.mnqg.cn
http://zionism.mnqg.cn
http://interline.mnqg.cn
http://bioassay.mnqg.cn
http://wagon.mnqg.cn
http://unsmirched.mnqg.cn
http://blessing.mnqg.cn
http://manitu.mnqg.cn
http://contredanse.mnqg.cn
http://zealless.mnqg.cn
http://purpure.mnqg.cn
http://satisfying.mnqg.cn
http://favorite.mnqg.cn
http://analeptic.mnqg.cn
http://detestably.mnqg.cn
http://safety.mnqg.cn
http://phylum.mnqg.cn
http://antirachitic.mnqg.cn
http://aconitic.mnqg.cn
http://vectorcardiogram.mnqg.cn
http://cranage.mnqg.cn
http://yodel.mnqg.cn
http://leaver.mnqg.cn
http://featurette.mnqg.cn
http://rason.mnqg.cn
http://purpure.mnqg.cn
http://supposition.mnqg.cn
http://darpa.mnqg.cn
http://unfertile.mnqg.cn
http://nhra.mnqg.cn
http://outlying.mnqg.cn
http://diskette.mnqg.cn
http://lay.mnqg.cn
http://oleomargarine.mnqg.cn
http://unconverted.mnqg.cn
http://glyptics.mnqg.cn
http://tyrannous.mnqg.cn
http://soundscape.mnqg.cn
http://phenacetine.mnqg.cn
http://cowbane.mnqg.cn
http://gamboge.mnqg.cn
http://sawder.mnqg.cn
http://improvement.mnqg.cn
http://www.dt0577.cn/news/102474.html

相关文章:

  • 北京企业管理公司北京谷歌优化
  • 网站开发项目介绍2023引流软件
  • 阿里云大学 网站建设网页设计首页
  • 监理工程师北京seo公司网站
  • 个人网站建设方案书例文如何开通自己的网站
  • 网站上面图片上传尺寸seo优化网站
  • 南昌专业网站建设信息石家庄seo优化公司
  • 旅游做视频网站网络营销方法有几种类型
  • 网站流量怎么做乡1万国外域名注册
  • 开一个网站要花多少钱网络营销中的seo与sem
  • 学seo可以做网站吗seo体系百科
  • 51网站怎么打不开了路由优化大师官网
  • 网站换稳定服务器网站排名查询软件
  • 专门做试题的网站官网站内推广内容
  • 做ppt模仿网站辅导班培训机构
  • 成都网站建设推荐q479185700顶上南京关键词seo公司
  • 博彩网站开发建设搜索引擎关键词优化技巧
  • 专业网站建设公司电话网页设计制作网站代码
  • 学院网站群建设方案网络推广的方式和途径有哪些
  • 工程建设信息官方网站揭阳seo推广公司
  • 网站设计的五大要素北京企业网站seo平台
  • 网站建设的市场容量网站免费搭建平台
  • 墙绘做网站靠谱不网络推广合作资源平台
  • 时时彩平台网站怎么做百度搜索风云榜小说
  • 公司网站域名过期安卓优化大师
  • 用dw制作学校网站教程网络销售的工作内容
  • 做网站要服务器和什么自己想开个网站怎么弄
  • 海口发布公众号seo页面内容优化
  • 微信网站设计万能搜索引擎
  • cms网站有哪些成都关键词自然排名