实现
final class ConfigUtil
object ConfigUtil {
def properties(): Properties = props()
private def props(): Properties = {
val properties = new Properties()
val env = sys.props.getOrElse("env", "dev")
properties.load(classOf[ConfigUtil].getResourceAsStream("/" + env + ".properties"))
properties
}
}
多环境区分
resources/dev.properties
resources/pro.properties
运行使用
java -jar demo.jar -Denv=pro