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

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

spring依賴注入的三種方式

2019-11-11 00:35:32
字體:
來源:轉載
供稿:網友

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;


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邵武市| 宽城| 琼海市| 汉中市| 青川县| 淄博市| 柯坪县| 建宁县| 咸阳市| 恩施市| 汉沽区| 枞阳县| 黔西县| 靖远县| 佳木斯市| 忻城县| 光泽县| 易门县| 富民县| 宜春市| 洛浦县| 宁德市| 荥经县| 东乡| 江都市| 黔西县| 民勤县| 巩留县| 泸水县| 蕲春县| 蓝山县| 咸丰县| 哈尔滨市| 苗栗县| 正安县| 东光县| 临海市| 株洲县| 清水河县| 互助| 甘泉县|