Created
August 30, 2021 11:24
-
-
Save JuliaKrivonos/cc1e926e98213ec2e903e98c43a6eab4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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