- package org.example;
-
- import java.util.Properties;
- import java.util.Set;
-
- public class Student {
- private Set
name; - private Properties info;
-
-
- public Set
getName() { - return name;
- }
-
- public void setName(Set
name) { - this.name = name;
- }
-
- public Properties getInfo() {
- return info;
- }
-
- public void setInfo(Properties info) {
- this.info = info;
- }
-
- @Override
- public String toString() {
- return "Student{" +
- "name=" + name +
- ", info=" + info +
- '}';
- }
- }

- "1.0" encoding="UTF-8"?>
"http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-
-
"student" class="org.example.Student"> -
"name"> -
-
张三 -
李四 -
王五 -
-
-
-
"info"> -
-
"姓名">张三 -
"学号">001 -
"年龄">20 -
-
-
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
-
- public class Test5 {
- public static void main(String[] args) {
- ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
- Student student=(Student) context.getBean("student");
- System.out.println(student);
- }
-
- }
