import com.hw.dao.UserDao; import com.hw.service.UserService; public class UserServiceImpl implements UserService { private UserDao userDao; public void setUserDao(UserDao userDao) { this.userDao = userDao; } @Override public void save() { System.out.println("userServiceImpl save runing..."); userDao.save(); } }
import java.util.*; public class UserDaoImpl implements UserDao { private ArrayList arrayList; private Properties prop; private int[] array; private HashSet set; private HashMap map; public void setArrayList(ArrayList arrayList) { this.arrayList = arrayList; } public void setProp(Properties prop) { this.prop = prop; } public void setArray(int[] array) { this.array = array; } public void setSet(HashSet set) { this.set = set; } public void setMap(HashMap map) { this.map = map; } @Override public void save() { System.out.println("UserDao dao running..."); System.out.println("arrayList" + arrayList); System.out.println("properties" + prop); System.out.println("set" + set); System.out.println("map" + map); System.out.println("array" + Arrays.toString(array)); } }
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="userDao" class="com.hw.dao.impl.UserDaoImpl" > <property name="prop"> <props> <prop key="name">zs</prop> <prop key="age">23</prop> </props> </property> <property name="arrayList"> <list> <value>aaa</value> <value>bbb</value> </list> </property> <property name="set"> <set> <value>aaa</value> <value>bbb</value> </set> </property> <property name="array"> <array> <value>111</value> <value>222</value> </array> </property> <property name="map"> <map> <entry key="username" value="zs" /> <entry key="password" value="123456" /> </map> </property> </bean> <bean id="userService" class="com.hw.service.impl.UserServiceImpl"> <property name="userDao" ref="userDao" /> </bean> </beans>
标签:set,void,System,println,集合,out,Ioc,public,注入 From: https://www.cnblogs.com/weiduaini/p/17289182.html