最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Spring實(shí)戰(zhàn)之搜索Bean類(lèi)操作示例

 更新時(shí)間:2019年12月18日 10:25:12   作者:cakincqm  
這篇文章主要介紹了Spring實(shí)戰(zhàn)之搜索Bean類(lèi)操作,結(jié)合實(shí)例形式分析了Spring搜索Bean類(lèi)的相關(guān)配置、接口實(shí)現(xiàn)與操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Spring實(shí)戰(zhàn)之搜索Bean類(lèi)操作。分享給大家供大家參考,具體如下:

一 配置文件

<?xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-4.0.xsd">
   <!-- 自動(dòng)掃描指定包及其子包下的所有Bean類(lèi) -->
   <context:component-scan
      base-package="org.crazyit.app.service"/>
</beans>

二 接口

Axe

package org.crazyit.app.service;
public interface Axe
{
   public String chop();
}

Person

package org.crazyit.app.service;
public interface Person
{
   public void useAxe();
}

三 Bean

Chinese

package org.crazyit.app.service.impl;
import org.springframework.stereotype.*;
import org.crazyit.app.service.*;
@Component
public class Chinese
  implements Person
{
  private Axe axe;
  // axe的setter方法
  public void setAxe(Axe axe)
  {
    this.axe = axe;
  }
  // 實(shí)現(xiàn)Person接口的useAxe()方法
  public void useAxe()
  {
    System.out.println(axe.chop());
  }
}

SteelAxe

package org.crazyit.app.service.impl;
import org.springframework.stereotype.*;
import org.crazyit.app.service.*;
@Component
public class SteelAxe implements Axe
{
  public String chop()
  {
    return "鋼斧砍柴真快";
  }
}

StoneAxe

package org.crazyit.app.service.impl;
import org.springframework.stereotype.*;
import org.crazyit.app.service.*;
@Component
public class StoneAxe implements Axe
{
  public String chop()
  {
    return "石斧砍柴好慢";
  }
}

四 測(cè)試類(lèi)

package lee;
import org.springframework.context.*;
import org.springframework.context.support.*;
public class BeanTest
{
  public static void main(String[] args)
  {
    // 創(chuàng)建Spring容器
    ApplicationContext ctx = new
      ClassPathXmlApplicationContext("beans.xml");
    // 獲取Spring容器中的所有Bean實(shí)例的名
    System.out.println("--------------" +
      java.util.Arrays.toString(ctx.getBeanDefinitionNames()));
  }
}

五 測(cè)試結(jié)果

--------------[chinese, steelAxe, stoneAxe,  org.springframework.context.annotation.internalConfigurationAnnotationProcessor,  org.springframework.context.annotation.internalAutowiredAnnotationProcessor,  org.springframework.context.annotation.internalRequiredAnnotationProcessor,  org.springframework.context.annotation.internalCommonAnnotationProcessor,  org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,  org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor]

更多關(guān)于java相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《Spring框架入門(mén)與進(jìn)階教程》、《Java數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Java操作DOM節(jié)點(diǎn)技巧總結(jié)》、《Java文件與目錄操作技巧匯總》和《Java緩存操作技巧匯總

希望本文所述對(duì)大家java程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • springBoot整合shiro如何解決讀取不到@value值問(wèn)題

    springBoot整合shiro如何解決讀取不到@value值問(wèn)題

    這篇文章主要介紹了springBoot整合shiro如何解決讀取不到@value值問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,
    2023-08-08
  • Mybatis關(guān)聯(lián)查詢(xún)結(jié)果集對(duì)象嵌套的具體使用

    Mybatis關(guān)聯(lián)查詢(xún)結(jié)果集對(duì)象嵌套的具體使用

    在查詢(xún)時(shí)經(jīng)常出現(xiàn)一對(duì)多”的關(guān)系,所有會(huì)出現(xiàn)嵌套對(duì)象的情況,本文主要介紹了Mybatis關(guān)聯(lián)查詢(xún)結(jié)果集對(duì)象嵌套的具體使用,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • Java中如何靈活獲取excel中的數(shù)據(jù)

    Java中如何靈活獲取excel中的數(shù)據(jù)

    這篇文章主要給大家介紹了關(guān)于Java中如何靈活獲取excel中的數(shù)據(jù),在日常工作中我們常常會(huì)進(jìn)行文件讀寫(xiě)操作,除去我們最常用的純文本文件讀寫(xiě),更多時(shí)候我們需要對(duì)Excel中的數(shù)據(jù)進(jìn)行讀取操作,需要的朋友可以參考下
    2023-07-07
  • Java多線程中的Phaser詳解

    Java多線程中的Phaser詳解

    這篇文章主要介紹了Java多線程中的Phaser詳解,Pahser是一個(gè)可以重復(fù)使用的同步屏障,Phaser是按照不同階段執(zhí)行線程的,它本身維護(hù)著一個(gè)叫 phase 的成員變量代表當(dāng)前執(zhí)行的階段,需要的朋友可以參考下
    2023-11-11
  • 解決springboot整合cxf-jaxrs中json轉(zhuǎn)換的問(wèn)題

    解決springboot整合cxf-jaxrs中json轉(zhuǎn)換的問(wèn)題

    這篇文章主要介紹了解決springboot整合cxf-jaxrs中json轉(zhuǎn)換的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • JAVA對(duì)象和字節(jié)數(shù)組互轉(zhuǎn)操作

    JAVA對(duì)象和字節(jié)數(shù)組互轉(zhuǎn)操作

    這篇文章主要介紹了JAVA對(duì)象和字節(jié)數(shù)組互轉(zhuǎn)操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-08-08
  • Java利用Geotools實(shí)現(xiàn)不同坐標(biāo)系之間坐標(biāo)轉(zhuǎn)換

    Java利用Geotools實(shí)現(xiàn)不同坐標(biāo)系之間坐標(biāo)轉(zhuǎn)換

    GeoTools 是一個(gè)開(kāi)源的 Java GIS 工具包,可利用它來(lái)開(kāi)發(fā)符合標(biāo)準(zhǔn)的地理信息系統(tǒng)。本文將利用工具包Geotools實(shí)現(xiàn)不同坐標(biāo)系之間坐標(biāo)轉(zhuǎn)換,感興趣的可以了解一下
    2022-08-08
  • Java8中stream流的collectingAndThen方法應(yīng)用實(shí)例詳解

    Java8中stream流的collectingAndThen方法應(yīng)用實(shí)例詳解

    Java8中的Stream流提供了collectingAndThen方法,用于對(duì)歸納結(jié)果進(jìn)行二次處理,文章通過(guò)User類(lèi)的數(shù)據(jù)填充,演示了如何使用該方法進(jìn)行集合去重、查找最高工資員工、計(jì)算平均工資等操作,感興趣的朋友跟隨小編一起看看吧
    2025-03-03
  • Springboot集成Kafka進(jìn)行批量消費(fèi)及踩坑點(diǎn)

    Springboot集成Kafka進(jìn)行批量消費(fèi)及踩坑點(diǎn)

    本文主要介紹了Springboot集成Kafka進(jìn)行批量消費(fèi)及踩坑點(diǎn),文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-12-12
  • 通過(guò)實(shí)例解析Java不可變對(duì)象原理

    通過(guò)實(shí)例解析Java不可變對(duì)象原理

    這篇文章主要介紹了通過(guò)實(shí)例解析Java不可變對(duì)象原理,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-10-10

最新評(píng)論

兴城市| 炉霍县| 永新县| 平潭县| 宁化县| 洪江市| 茶陵县| 天祝| 饶平县| 集安市| 台前县| 庄河市| 永康市| 三门峡市| 宜昌市| 马山县| 梁平县| 禄丰县| 柳州市| 滦南县| 文安县| 读书| 九江市| 巍山| 光山县| 腾冲县| 宁德市| 尉犁县| 安溪县| 枣庄市| 秦安县| 卓资县| 连江县| 湘潭县| 乌审旗| 偃师市| 塔河县| 巴东县| 扎囊县| 长海县| 雅江县|