@ConfigurationProperties 取值为空的问题

当取 spring.redis.cluster.nodes =47.111 这样多个点的值时,

如果用 驼峰式的clusterNodes来取值为null,但有多层时需要重新创建一个类来接受,才能取到值

@Data
@ConfigurationProperties(prefix = "spring.redis")
public class RedissonConfig {

    private ClusterProperties cluster = new ClusterProperties() ;
    private String password;
    private String database;

    private String clusterNodes;


    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public class ClusterProperties {
        private String nodes;
    }
}

 

 
 

你可能感兴趣的:(java,spring,boot,java)