spring-自动装配,继承,抽象,依赖注意点-复习-4

这一次得出的结论是depend-on和autowire结合使用,autowire在指定了parent后可能不会再次装配。

其次是abstract的数据模板功能,同时不能被容器实例化。 



	
	
	
	
	
		
	
	
		
	
	
	
		
			
		
		
			
		
		
			
		
		
	
	
	
	
	
	
	
	
	
		
			
				
				
					
				
			
		
		
			
				
				
					
				
				
					
						
					
				
			
		
		
			
				485118-546548-2198765-879845
				895118-556548-2198765-109845
			
		
	

 

package com.springstudy.test;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.springstudy.vo.Customer;

class CustomerTest {
	static ApplicationContext ctx; 
	Customer springCustomer=ctx.getBean("customer", Customer.class);
	Customer springCustomer2=ctx.getBean("customer2", Customer.class);
	Customer springCustomer3=ctx.getBean("customer3", Customer.class);
	@BeforeAll
	static void setUpBeforeClass() throws Exception {
		ctx = new ClassPathXmlApplicationContext("PCBU01.xml");
	}

	@Test
	void test() {
		//springCustomer.getLstOrds().forEach(x->System.out.println(x.getId()));
		springCustomer.getMapOrds().forEach((x,y)->System.out.println(x+"->"+y.getId()));
		springCustomer.getProps().forEach((x,y)->System.out.println(x+"->"+y));
		
		springCustomer2.getLstOrds().forEach(x->System.out.println(x.getId()));
		
		springCustomer3.getLstOrds().forEach(x->System.out.println(x.getId()));
	}

}
100000971956->1
2912105->2
291210599->3
Cat10598->485118-546548-2198765-879845
Cat10508->895118-556548-2198765-109845
1
3
10
11
14
1

 

你可能感兴趣的:(SSH,SSI)