Advertisement

掌握Spring依赖注入的方法

阅读量:

Spring 框架对 Java Bean 的管理主要依赖于依赖注入机制,即控制反转(IOC)原理。该机制包含三种实现方式:属性注入、构造函数注入以及工厂方法注入,其中工厂方法又细分为静态与非静态两种类型,其区分依据在于方法是否为静态方法。

People类:

复制代码
 package com.xiaowu.entity;

    
  
    
 public class People {
    
 	int id;
    
 	String name;
    
 	int age;
    
 	
    
 	
    
 	
    
 	public People() {
    
 		super();
    
 		// TODO Auto-generated constructor stub
    
 	}
    
 	public People(int id, String name, int age) {
    
 		super();
    
 		this.id = id;
    
 		this.name = name;
    
 		this.age = age;
    
 	}
    
 	public int getId() {
    
 		return id;
    
 	}
    
 	public void 

全部评论 (0)

还没有任何评论哟~