我有一个spring启动应用程序,并希望通过环境变量设置一个类,该类使用@ConfigurationProperties第二级嵌套属性进行注释,该属性是驼峰式的.以下是该类的示例:
@SpringBootApplication
@EnableConfigurationProperties(SpringApp.Props.class)
@RestController
public class SpringApp {
private Props props;
@ConfigurationProperties("app")
public static class Props {
private String prop;
private Props nestedProps;
public String getProp() {
return prop;
}
public void setProp(String prop) {
this.prop = prop;
}
public Props getNestedProps() {
return nestedProps;
}
public void setNestedProps(Props nestedProps) {
this.nestedProps = nestedProps;
}
}
@Autowired
public void setProps(Props props) {
this.props = props;
}
public static void main(String[] args) {
SpringApplication.run(SpringApp.class, args);
}
@RequestMapping("/")
Props getProps() …Run Code Online (Sandbox Code Playgroud)