无参构造
xml中
<bean id="userDao" class="com.wjb.dao.impl.UserDaoImpl" scope="singleton" init-method="init" destroy-method="destory"></bean>
test
package com.wjb.test; import com.wjb.dao.UserDao; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class SpringTest { @Test //测试scope属性 public void test1(){ ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml"); UserDao userDao1 = (UserDao) app.getBean("userDao"); System.out.println(userDao1); } }
原创文章,作者:254126420,如若转载,请注明出处:https://blog.ytso.com/270709.html