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

化妆品网站优势他达拉非片和伟哥区别

化妆品网站优势,他达拉非片和伟哥区别,展馆展示设计公司招聘信息,wordpress网站调用导航菜单目录 Bean的别名:id和name的地位等同 Bean的作用范围:scope单例与非单例 Bean的使用场景:什么时候交给容器?什么时候不交?​ Bean的别名实践(含代码) 如果看不懂下面的,例如不知道i…

目录

Bean的别名:id和name的地位等同

 Bean的作用范围:scope单例与非单例

 Bean的使用场景:什么时候交给容器?什么时候不交?​

 Bean的别名实践(含代码)


如果看不懂下面的,例如不知道id写在哪里的,请首先看这篇博文:Spring的IoC、Bean、DI的简单实现,难度:※※※-CSDN博客


 

Bean的别名:id和name的地位等同

 Bean的作用范围:scope单例与非单例

 Bean的使用场景:什么时候交给容器?什么时候不交?

 Bean的别名实践(含代码)

案例一:

 案例二:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><bean id="cat" class="org.example.package2.Cat"/><bean id="dog" class="org.example.package2.Dog"/><bean id="animalSet" name="abc1234" class="org.example.AnimalSet"><property name="animal1" ref="cat"></property><property name="animal2" ref="cat"></property></bean>
</beans>

package org.example;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Main {public static void main(String[] args) {ApplicationContext iocContext = new ClassPathXmlApplicationContext("applicationConfig.xml");AnimalSet animalSet = (AnimalSet) iocContext.getBean("abc1234");System.out.println(animalSet);animalSet.animalSetSound();}
}
package org.example;import org.example.package1.Animal;public class AnimalSet{Animal animal1;Animal animal2;public void animalSetSound(){animal1.sound();animal2.sound();}public void setAnimal1(Animal animal1) {this.animal1 = animal1;}public void setAnimal2(Animal animal2) {this.animal2 = animal2;}}
package org.example.package2;
import org.example.package1.Animal;public class Cat implements Animal{@Overridepublic void sound(){System.out.println("cat sound");}
}
package org.example.package2;import org.example.package1.Animal;public class Dog implements Animal {public void sound() {System.out.println("dog sound");}
}
package org.example.package1;public interface Animal {void sound();
}

http://www.hkea.cn/news/915184/

相关文章:

  • 做游戏赚钱的网站最新新闻热点事件2022
  • 商务网站建设哪家好推广代理公司
  • 自己做网站是否要买云主机西安百度提升优化
  • 成都注册公司哪个区好分析网站推广和优化的原因
  • 模板建站杭州seo泽成
  • 济南网站建设公司川芎网络怎么注册自己的网址
  • linux下安装wordpress关键词优化排名查询
  • wordpress手机网站怎么做中央电视台一套广告价目表
  • 百家号如何给网站做推广推广方案是什么
  • 西安三网合一网站建设产品线上推广方案
  • 2023年免费b站入口百度网站优化
  • 响应式网站建设有利于seo网站发布与推广方案
  • 网页制作教程课件seo推广排名重要吗
  • 小规模纳税人企业所得税怎么征收广州seo招聘
  • 济南企业自助建站网络营销策划公司
  • iis 新建网站 要登录温州seo推广外包
  • 个人想做企业网站备案惠州seo代理商
  • 做公务员题的网站口红的推广软文
  • 福州网站建设 联系yanktcn 04上海百网优seo优化公司
  • 网站备案号如何获得网站建设营销推广
  • 物流网站开发公司西安 做网站
  • 商务信息网站怎么做网络视频营销策略有哪些
  • 社交做的最好的网站怎么开发一个网站
  • 教育品牌网站建设百度搜索推广和信息流推广
  • 虎门专业做网站对网络营销的认识有哪些
  • 投资理财培训网站建设抖音引流推广一个30元
  • 做景观设施的网站网络营销推广要求
  • 携程网站建设进度及实施过程网络营销的缺点及建议
  • 石家庄网站建设哪家专业中国联通腾讯
  • 能访问各种网站的浏览器百度一下网页搜索