<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<context:component-scan base-package="com.zj.ioc.demo"></context:component-scan>
</beans>
package com.zj.ioc.demo;
interface People {
}
package com.zj.ioc.demo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Student implements People{
@Value("8888")
private Integer id;
@Value("学生")
private String name;
public Student(Integer id, String name) {
super();
this.id = id;
this.name = name;
}
public Student() {
super();
}
public Integer getId() {
return id;
}
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + "]";
}
public void setId(Integer id