【Springboot获取自定义配置文件的的值】

Springboot获取自定义配置文件的的值

package com.xl.test.springtest.pojo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix="aaa",ignoreUnknownFields = false)
@PropertySource("classpath:myconfig/myconfig.properties")
public class MyConfig {
	
	private String x;
	
	private String y;
	
	private String z;

	public String getX() {
		return x;
	}

	public void setX(String x) {
		this.x = x;
	}

	public String getY() {
		return y;
	}

	public void setY(String y) {
		this.y = y;
	}

	public String getZ() {
		return z;
	}

	public void setZ(String z) {
		this.z = z;
	}
	
	
}

测试:
【Springboot获取自定义配置文件的的值】_第1张图片
【Springboot获取自定义配置文件的的值】_第2张图片

你可能感兴趣的:(#,spring笔记,Springboot,自定义配置文件)