com.github.azbh111.starter.config.AppConfigProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of app-config-spring-boot-starter Show documentation
Show all versions of app-config-spring-boot-starter Show documentation
com.github.azbh111:app-config-spring-boot-starter
The newest version!
package com.github.azbh111.starter.config;
import lombok.ToString;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
import java.util.List;
/**
* @author pyz
* @date 2019/10/19 5:13 下午
*/
@ToString
@ConfigurationProperties("spring.application")
public class AppConfigProperties implements InitializingBean {
private String name;
private RuntimeEnvironment runtimeEnvironment;
private DataEnvironment dataEnvironment;
private List basePackages;
private List basePackageExecludes;
@Override
public void afterPropertiesSet() throws Exception {
if (name == null || name.isEmpty()) {
throw new Error("缺少配置: spring.application.name");
}
if (runtimeEnvironment == null) {
throw new Error("缺少配置: spring.application.runtimeEnvironment");
}
if (dataEnvironment == null) {
throw new Error("缺少配置: spring.application.dataEnvironment");
}
if (basePackages == null || basePackages.isEmpty()) {
throw new Error("配置为空: spring.application.basePackages");
}
if (basePackageExecludes == null) {
basePackageExecludes = new ArrayList<>();
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public RuntimeEnvironment getRuntimeEnvironment() {
return runtimeEnvironment;
}
public void setRuntimeEnvironment(RuntimeEnvironment runtimeEnvironment) {
this.runtimeEnvironment = runtimeEnvironment;
}
public DataEnvironment getDataEnvironment() {
return dataEnvironment;
}
public void setDataEnvironment(DataEnvironment dataEnvironment) {
this.dataEnvironment = dataEnvironment;
}
public List getBasePackages() {
return basePackages;
}
public void setBasePackages(List basePackages) {
this.basePackages = basePackages;
}
public List getBasePackageExecludes() {
return basePackageExecludes;
}
public void setBasePackageExecludes(List basePackageExecludes) {
this.basePackageExecludes = basePackageExecludes;
}
}