0
0
springboot自定义yml配置(配合lombak使用)
文章摘要
|
application.yml
application:
admin:
allow-delete: enabled
allow-register: enabled
AdminConfig.java
/**
* 管理员相关配置
*
* @author xclhove
*/
@Component
@ConfigurationProperties(prefix = "cheetah.admin")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AdminConfig {
private AllowRegister allowRegister;
private AllowDelete allowDelete;
}
AllowDelete
/**
* 是否开启删除管理员功能
*
* @author xclhove
*/
@Getter
@AllArgsConstructor
public enum AllowDelete {
ENABLED(true, "允许删除管理员"),
DISABLED(false, "不允许删除管理员");
private final boolean value;
private final String description;
}
AllowRegister
/**
* 是否开启管理员注册功能
*
* @author xclhove
*/
@Getter
@AllArgsConstructor
public enum AllowRegister {
ENABLED(true, "允许管理员注册"),
DISABLED(false, "不允许管理员注册");
private final boolean value;
private final String description;
}
