国产探花免费观看_亚洲丰满少妇自慰呻吟_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;


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 瑞金市| 肃宁县| 宜丰县| 肃北| 莱州市| 琼海市| 丰镇市| 海盐县| 仁化县| 芒康县| 泰宁县| 甘南县| 恩施市| 东阿县| 郓城县| 平凉市| 宣化县| 海安县| 咸阳市| 时尚| 八宿县| 西城区| 长顺县| 江川县| 鄯善县| 门头沟区| 浦县| 柯坪县| 集贤县| 乐都县| 永顺县| 大姚县| 策勒县| 永川市| 东源县| 秭归县| 微博| 大英县| 民权县| 彭阳县| 竹山县|