框架|springboot把配置实体和配置文件关联

【框架|springboot把配置实体和配置文件关联】1.实体

package com.tansen.study.springbootssm.bean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @Component @ConfigurationProperties(prefix = "druid.config") public class DruidConifg { private String allow; private String deny; private String loginUsername; private String loginPassword; private String resetEnable; get/set... }

2.配置文件(application.properties)
druid.config.allow=127.0.0.1 druid.config.deny=192.168.0.19 druid.config.loginUsername=druid druid.config.loginPassword=123456 #是否可以重置数据 druid.config.resetEnable=false

    推荐阅读