Spring--注入集合类型的属性

 UserServiceImpl:

/**
 * 业务层实现类
 */
public class UserServiceImpl implements UserService {

    private UserDao userDao;
    private String[] myStrs;
    private List myList;
    private Set mySet;
    private Map myMap;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void setMyStrs(String[] myStrs) {
        this.myStrs = myStrs;
    }

    public void setMyList(List myList) {
        this.myList = myList;
    }

    public void setMySet(Set mySet) {
        this.mySet = mySet;
    }

    public void setMyMap(Map myMap) {
        this.myMap = myMap;
    }

    public void addUser(){
        System.out.println(Arrays.toString(myStrs));
        System.out.println(myList);
        System.out.println(mySet);
        System.out.println(myMap);
        userDao.addUser();
    }
}

applicationContext.xml:




    
    
    
        
        
        
        
            
                AAA
                BBB
                CCC
            
        
        
        
            
                AAA
                BBB
                CCC
            
        
        
        
            
                AAA
                BBB
                CCC
            
        
        
        
            
                
                
            
        
    

你可能感兴趣的:(spring,linux,java,intellij-idea)