import java.util.ResourceBundle; /** * 读取properties文件的帮助类 * @author */ public class PropertiesUtil { public static String getPropertyValue(String fileName, String key) { ResourceBundle bundle = ResourceBundle.getBundle(fileName); String value = bundle.getString(key); return value; } }
使用时只需要执行以下代码就可以获取到application.properties配置文件中img.upload的值
public static final String IMG_UPLOAD = PropertiesUtil.getPropertyValue("application", "img.upload");
时间: 2024-12-29 10:36:28