1. 程式人生 > >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