运行时报错:Failed to bind properties under 'limit'

来源:4-1 项目属性配置知多少

weixin_慕雪9198457

2021-01-20 14:24


APPLICATION FAILED TO START

***************************


Description:


Failed to bind properties under 'limit' to com.imooc.luckymoney.LimitConfig:


    Property: limit.description

    Value: at least ${limit.minMoney} yuan, at most ${limit.maxMoney} yuan

    Origin: class path resource [application.yml]:9:16

    Reason: No setter found for property: description


Action:


Update your application's configuration



运行时报错这个,写的码跟老师 的一样,为什么还是会有这个错误呢


写回答 关注

1回答

  • 小羊爱主
    2021-02-15 17:34:49
    看看下面的粗体字,description有没有setter方法?

    package com.imooc.luckymoney;

    import java.math.BigDecimal;

    import org.springframework.beans.factory.annotation.Value;

    import org.springframework.boot.context.properties.ConfigurationProperties;

    import org.springframework.stereotype.Component;

    @Component

    @ConfigurationProperties(prefix = "limit")

    public class LimitConfig {

    private BigDecimal minMoney;

    private BigDecimal maxMoney;

    private String description;

    public BigDecimal getMinMoney() {

    return minMoney;

    }

    public void setMinMoney(BigDecimal minMoney) {

    this.minMoney = minMoney;

    }

    public BigDecimal getMaxMoney() {

    return maxMoney;

    }

    public void setMaxMoney(BigDecimal maxMoney) {

    this.maxMoney = maxMoney;

    }

    public String getDescription() {

    return description;

    }

    public void setDescription(String description) {

    this.description = description;

    }


    }


2小时上手SpringBoot

2小时上手SpringBoot,实战开发红包表白程序,体现程序员专属花式浪漫

11882 学习 · 115 问题

查看课程

相似问题