Maple's Blog.

bootstrap.yaml 参数获取

字数统计: 53阅读时长: 1 min
2022/12/06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import lombok.Data;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Value;

/**
* @author maple
* @since 2022-12-06
*/
@Data
@Component
public class GatewayProperties {
@Value("${gateway.host}")
private String host;
}

1
2
3
4
5
6
7
8
class Test {
@Autowired
private GatewayProperties gatewayProperties;

void Test() {
String url = gatewayProperties.getHost();
}
}
CATALOG