在编写代码时,有时候会有很多文件生成需要同一个路径,统一修改,所以要写在yml文件中,再编写一个类读取,并保存属性,
但是有时候,这个属性需要放在静态方法中使用,必须修改相应的属性才能进行使用,但是有时只给属性加入static属性并不够,有时还是会获取不到,所以就定义了getset方法,进行获取
@Configuration
@PropertySource(value={"classpath:bootstrap.yml"})
@ConfigurationProperties(prefix = "freemark.path" )
public class FreemarkProperties {
public static String generatePath;
public static String importPath;
@Value("${generatePath}")
public void setGeneratePath(String generatePath)
{
FreemarkProperties.generatePath = generatePath;
}
public static String getGeneratePath()
{
return generatePath;
}
@Value("${importPath}")
public void setImportPath(String importPath)
{
FreemarkProperties.importPath = importPath;
}
public static String getImportPath()
{
return importPath;
}
}