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

首頁 > 學院 > 開發(fā)設計 > 正文

spring依賴注入的三種方式

2019-11-10 23:49:52
字體:
供稿:網(wǎng)友

1.接口注入

2.getter,setter注入

3.構(gòu)造器注入

1.接口注入

2.setter注入

     <bean id="book" class="com.PRoperty.Book">		<property name="bookName" value="java核心技術(shù)"></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.構(gòu)造器注入

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;


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 陕西省| 合阳县| 庆云县| 辰溪县| 监利县| 屯门区| 齐河县| 蒙城县| 新疆| 永州市| 台东市| 深水埗区| 姜堰市| 车险| 晋城| 金坛市| 星子县| 南川市| 长顺县| 会东县| 华安县| 淳化县| 北安市| 勐海县| 承德县| 肇东市| 正定县| 海林市| 金门县| 郯城县| 开远市| 堆龙德庆县| 西乡县| 富源县| 霍邱县| 渑池县| 阿坝县| 保山市| 莱阳市| 鄂州市| 莱阳市|