国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

spring依賴注入的三種方式

2019-11-10 23:28:28
字體:
來源:轉載
供稿:網友

1.接口注入

2.getter,setter注入

3.構造器注入

1.接口注入

2.setter注入

     <bean id="book" class="com.PRoperty.Book">		<property name="bookName" value="java核心技術"></property>     </bean> 

package com.property;public class Book {	private String bookName;		public void setbookName(String bookName){		this.bookName = bookName;	}		public void demoBook(){		System.out.println("..........."+this.bookName);	}}3.構造器注入

package com.property;public class Property {	private String name;	public Property(String name){		this.name = name;	}	public void test(){		System.out.println("............."+name);	}	}
     <bean id="property" class="com.chen.property.Property">         <constructor-arg name="name" value="java">               </constructor-arg>     </bean>或者是

     <bean id="property" class="com.property.Property">         <constructor-arg index="0" value="java" >               </constructor-arg>              </bean>

接口注入

package com.hanson.ssm.service;import java.util.List;import java.util.Map;import com.hanson.ssm.pojo.Clothes;public interface ClothesService {	public  List<Clothes> findClothesList();	}@Servicepublic class ClothesServiceImpl implements ClothesService{	@Override	public List<Clothes> findClothesList() {		List<Clothes> clothesList = clothesCustomMappers.findClothesList();		return clothesList;	}}	@Autowired	private ClothesService clothesService;

package com.hanson.ssm.service;import java.util.List;import java.util.Map;import com.hanson.ssm.pojo.Clothes;public interface ClothesService {	public  List<Clothes> findClothesList();	}@Servicepublic class ClothesServiceImpl implements ClothesService{	@Override	public List<Clothes> findClothesList() {		List<Clothes> clothesList = clothesCustomMappers.findClothesList();		return clothesList;	}}	@Autowired	private ClothesService clothesService;
	@Autowired	private ClothesService clothesService;


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨江| 永州市| 贵溪市| 鸡东县| 黄陵县| 周口市| 扶余县| 大田县| 酒泉市| 许昌县| 太谷县| 江口县| 和田市| 白沙| 嘉定区| 北安市| 和龙市| 含山县| 额敏县| 工布江达县| 蒙城县| 云南省| 福州市| 鄄城县| 金塔县| 梨树县| 阿尔山市| 延安市| 永仁县| 祁连县| 花莲市| 达拉特旗| 阿拉善左旗| 武隆县| 长沙县| 唐海县| 清远市| 彭水| 白朗县| 五原县| 成安县|