- public class Student{
- private String[] books;
- private List
hobbies; - private Map
card; -
- public String[] getBooks() {
- return books;
- }
-
- public void setBooks(String[] books) {
- this.books = books;
- }
-
- public List
getHobbies() { - return hobbies;
- }
-
- public void setHobbies(List
hobbies) { - this.hobbies = hobbies;
- }
-
- public Map
getCard() { - return card;
- }
-
- public void setCard(Map
card) { - this.card = card;
- }
-
- @Override
- public String toString() {
- return "Student{" +
- "books=" + Arrays.toString(books) +
- ", hobbies=" + hobbies +
- ", card=" + card +
- '}';
- }
- }
- "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"> -
-
"books"> -
-
三国演义 -
红楼梦 -
水浒传 -
西游记 -
-
-
-
-
"hobbies"> -
-
篮球 -
画画 -
音乐 -
-
-
-
-
"card"> -
-
"身份证" value="1111111" /> -
"银行卡" value="22222" /> -
-
-
-
-
-
-
- public class Test4 {
- public static void main(String[] args) {
- ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
- Student student=(Student) context.getBean("student");
- System.out.println(student.toString());
- }
- }