[英]No error message during Spring Boot launch for nested @ConfigurationProperties
在我的 spring boot 应用程序中,我有一个类来处理 application.properties 文件
@Validated
@ConfigurationProperties(prefix = "cassandre.trading.bot.exchange")
public class ExchangeParameters
这个类有这样的属性:
/** Exchange name. For example : coinbase, kraken, kucoin. */
@NotEmpty(message = "Exchange name required, for example : coinbase, kraken, kucoin...")
private String name;
/** API username. */
@NotEmpty(message = "API username required")
private String username;
如果 spring boot 找不到它们,我会收到正确的错误消息,例如:
Property: cassandre.trading.bot.exchange.secret
Value: null
Reason: API secret required
Property: cassandre.trading.bot.exchange.name
Value: null
Reason: Exchange name required, for example : coinbase, kraken, kucoin...
但是在我的班级中,我也有嵌套的属性:
/** Modes. */
@Valid
private static Modes modes = new Modes();
/** API Calls rates. */
@Valid
private static Rates rates = new Rates();
/** Exchange API rate calls. */
@ConfigurationProperties(prefix = "cassandre.trading.bot.exchange.modes")
public static class Modes {
/** Set it to true to use the sandbox. */
@NotNull(message = "Sandbox parameter required, set it to true to use the sandbox")
private Boolean sandbox;
/** Set it to true to use the dry mode. */
@NotNull(message = "Dry parameter required, set it to true to use the dry mode")
private Boolean dry;
如果缺少费率,我会收到有关费率的正确消息。
但是我根本没有设置任何参数,除了速率之类的嵌套属性外,所有字段都有错误消息。
任何的想法 ? 多谢
我找到了解决方案。 不要使用静态字段和类
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.