springboot 启动后将yml文件变量加载到指定的静态文件里面

import org.springframework.beans.factory.annotation.Value;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

@Configuration

public class ConfigUtil {

@Value("${hdfs.path}")

private StringhdfsPath;

@Value("${hdfs.username}")

private Stringusername;

@Bean

    public int initStatic(){

DataUtil.setHdfsPath(hdfsPath);

DataUtil.setUsername(username);

return 0;

}

}

你可能感兴趣的:(springboot 启动后将yml文件变量加载到指定的静态文件里面)