Spring_Bean 之间的关系

beans-relation.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<!--
<bean >
</bean>
-->

<!--
抽象bean: bean的 abstract属性为true的bean. 这样的bean不能被IOC 容器实例化,只能被继承配置
若某一个bean的class 属性没有指定,则该bean必须是一个抽象的bean
-->
<bean >
</bean>

</beans>

Main.java

package com.hy.spring.beans.relation;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.hy.spring.beans.autowire.Address;

public class Main {

public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("beans-relation.xml");
//Address address = (Address) ctx.getBean("address");
//System.out.println(address);
Address address = (Address) ctx.getBean("address1");
System.out.println(address);
}

}

 Spring_Bean 之间的关系

 

XML 配置

<bean >
</bean>

 

相关文章:

  • 2021-10-25
猜你喜欢
  • 2021-06-18
  • 2021-07-26
  • 2021-08-29
  • 2021-10-22
  • 2021-07-10
  • 2021-11-22
相关资源
相似解决方案