标签:class blog code java http ext
构造方法类Bean1
package com.hao947.bean; public class Bean1 { public Bean1() { System.out.println("bean1...构造方法"); } public void show(){ System.out.println("bean1...方法"); } }
<?xml version="1.0" encoding="UTF-8"?> <!-- 整个Spring文件根元素就是beans --> <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-3.1.xsd"> <!-- 此处及用Bean元素来定义Spring能创建的对象 --> <bean id="bean1" class="com.hao947.bean.Bean1"> </bean> </beans>
public class InitBeanApp { @Test public void show() { ApplicationContext ac = new ClassPathXmlApplicationContext( "applicatioContext.xml"); Bean1 bs = (Bean1) ac.getBean("bean1"); System.out.println(bs); } }
bean1...构造方法
com.hao947.bean.Bean1@663b1f38
Spring 类构造器初始化实例,布布扣,bubuko.com
标签:class blog code java http ext
原文地址:http://blog.csdn.net/hao947_hao947/article/details/31419561