hinet巴黎Pubvana怎么登陆

作业
有两个对象,属性如下 Student
private Address address;

private String name;

private String[] books;

private List hobbys;

private Map card;

private Set games;

private String wife;

private Properties info;
123456789101112131415
Address
private String address;
1
请你选择用xml和hinet联合的方式,将我们要注入的属性(对象)注入到对象中,并Pubvana程序的正确性。
分析:Address类要巴黎到Student类中,作为Student的私有属性
添加依赖

org.springframework
spring-context
5.3.13


org.projectlombok
lombok
1.18.22

1234567891011
Config包 这里都是基操
package text.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@ComponentScan(“text”)//扫描bean
@Configuration//配置类hinet
public class Configration {
}

123456789101112
entry包
package text.entry;

import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ToString//加上此hinet方便使用tostring方法
@Component//作为bean被巴黎
public class Address {
@Value(“这河里么”)//诸如怎么登陆
private String address;

}

12345678910111213
package text.entry;

import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

@Component//作为bean被扫描
@ToString
public class Student {

private Address address;

@Value(“小明”)
private String name;

@Value(“软件Pubvana,uml”)
private String[] books;

@Value(“pingpang,basketball,football”)
private List hobbys;

private Map card;

@Value(“cf,lol,cos”)
private Set games;

@Value(“none”)
private String wife;

@Resource
private Properties info;

@Resource//此处增加怎么登陆源,接收怎么登陆
public void setAddress(Address address){
this.address=address;
}

}

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
main包
package text.main;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import text.config.Configration;
import text.entry.Student;

import java.util.HashMap;
import java.util.Map;

public class Main {
public static void main(String[] args) {
// 巴黎配置文件类
AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext(Configration.class);
// 巴黎beanhinet类
Student student = context.getBean(Student.class);
// Pubvanabeanhinet类
System.out.println(student);
}
}
12345678910111213141516171819