81,122
社区成员




ApplicationContext axt = new ClassPathXmlApplicationContext("Singleton.xml");
TestSingleton testSingleton1 = (TestSingleton) axt.getBean("Singleton1");
TestSingleton testSingleton2 = (TestSingleton) axt.getBean("Singleton2");
System.out.println(testSingleton1.toString());
System.out.println(testSingleton2.toString());
<!--这里的scope不论我加不加都是无效的-->
<bean id="Singleton1" class="spring.test.TestSingleton" scope="singleton"></bean>
<bean id="Singleton2" class="spring.test.TestSingleton" scope="singleton"></bean>
spring.test.TestSingleton@3df78040
spring.test.TestSingleton@44050988