SpringBoot使用自定义的配置文件
怎么用
-
新建自定义的配置文件,并且在自定义的配置文件中输入内容


-
新建配置类,并且使用注解component,ConfigurationProperties(prefix为配置文件中的前缀),PropertySource
@Component
@ConfigurationProperties(prefix = "jb")
@PropertySource("classpath:/config.properties")
@Data
public class ConfigProperties {
private String officialUrl;
private String testUrl;
}

浙公网安备 33010602011771号