test.java
ApplicationContext context =
new ClassPathXmlApplicationContext("beans.xml");
HelloWorldService service =
(HelloWorldService) context.getBean("helloWorldService");
//往helloWorldService里面注入springHelloWorld
applicationContext.xml:
<bean id="" class=""></bean>
<bean id="" class="">
<propertyname="" ref=""/> 这里输入要引用的别的对象,要写入bean的id
</bean>
ApplicationContext context =
new ClassPathXmlApplicationContext("beans.xml");
HelloWorldService service =
(HelloWorldService) context.getBean("helloWorldService");
//往helloWorldService里面注入springHelloWorld
applicationContext.xml:
<bean id="" class=""></bean>
<bean id="" class="">
<propertyname="" ref=""/> 这里输入要引用的别的对象,要写入bean的id
</bean>