Skip to content

Instantly share code, notes, and snippets.

@JuliaKrivonos
Created August 30, 2021 11:24
Show Gist options
  • Select an option

  • Save JuliaKrivonos/cc1e926e98213ec2e903e98c43a6eab4 to your computer and use it in GitHub Desktop.

Select an option

Save JuliaKrivonos/cc1e926e98213ec2e903e98c43a6eab4 to your computer and use it in GitHub Desktop.
package org.jazzteam.fitnesclub.repository.jdbc;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Paths;
import java.util.Properties;
@Slf4j
public class PropertyUtil {
private static final String APPLICATION_PROPERTIES_PATH = "application.properties";
private static final Properties properties = new Properties();
static {
loadProperties();
}
private static void loadProperties() {
try (InputStream inputStream = PropertyUtil.class.getClassLoader()
.getResourceAsStream(APPLICATION_PROPERTIES_PATH)) {
properties.load(inputStream);
} catch (IOException ex) {
log.error(ex.getMessage());
throw new IllegalStateException("Config file not found by path " + Paths.get(APPLICATION_PROPERTIES_PATH));
}
}
private PropertyUtil() {
}
public static String getProperty(String key) {
return properties.getProperty(key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment