SpringIoc综合案例 这里采用方案一 配置文件的方式 方案二 注解的方式+配置文件的方式 方案三 不使用配置文件的方式
package com.spring.entity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* 一个标准类的封装
*/
@Component(value = "animal")
public class Animal {
@Value("1003")
private int id;
@Value("这里调用的是Car对象的内容小喵喵")
private String name;
@Value("20")
private String age;
@Value("白色")
private String color;
@Value("120")
private int height;
@Value("23")
private int weight;
@Value("X的未知数")
private Object x;
@Autowired
private Student student;