小编rab*_*nda的帖子

spring-boot camel case嵌套属性作为环境变量

我有一个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)

java environment-variables spring-boot

7
推荐指数
1
解决办法
1294
查看次数

标签 统计

environment-variables ×1

java ×1

spring-boot ×1