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;
}
}
测试类文章来源:https://www.toymoban.com/news/detail-612441.html
@Test
void testUrl(){
System.out.println(creditInvestProperties.getReportUrl());
}
文章来源地址https://www.toymoban.com/news/detail-612441.html
到了这里,关于springboot拿到yml文件中的配置,决绝将配置写在代码里的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!