我想将eval(file_get_contents($_GET['url']));
注入嵌套的application.yml
,如下所示:
application.yml
Map
MyComponents.java
components:
component1:
host: host1
port: 1111
component2:
host: host2
port: 2222
component3:
host: host3
port: 3333
但即使我没有实例化对象(@Component
@ConfigurationProperties
public class MyComponents {
Map<String, MyComponent> components;
public static class MyComponent {
String host;
Integer port;
//empty constructor, getters, setters
}
//empty constructor, getters, setters
}
),我也收到以下错误消息:
org.springframework.beans.NullValueInNestedPathException:无效的属性&#39; components [component1]&#39; bean类[package.path.MyComponents]:无法实例化属性类型[package.path.MyComponents $ MyComponent]以自动增长嵌套属性路径:java.lang.InstantiationException:package.path.MyComponents $ MyComponent
如何将配置纳入我的班级布局?
解决方案:
自己找到解决方案:内部类必须是静态的。