springboot拿到yml文件中的配置
写你对应的文件
package com.gym.vueea.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @author ymgu
* @Package com.gym.vueea.config
* @date 2023/7/28 14:19
*/
@Component
@ConfigurationProperties(prefix = "credit-invest")
public class CreditInvestProperties {
private String serviceUrl;
private String reportUrl;
public String getServiceUrl() {
return serviceUrl;
}
public void setServiceUrl(String serviceUrl) {
this.serviceUrl = serviceUrl;
}
public String getReportUrl() {
return reportUrl;
}
public void setReportUrl(String reportUrl) {
this.reportUrl = reportUrl;
}
}
测试类
@Test
void testUrl(){
System.out.println(creditInvestProperties.getReportUrl());
}