下面的代码是已知配置文件里面的内容,将里面的值给拿出来设置给实体类的有参构造函数。
package chapte2;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.Properties;
public class chapte2 {
public static void main(String[] args) throws Exception {
Properties properties=new Properties();
ClassLoader classLoader=chapte2.class.getClassLoader(); //getClassLoader()这个是获取根路径下的,如果不是src下,得记得加上包名
InputStream inputStream=classLoader.getResourceAsStream("chapte2/aplication.properties"