Primer commit: se crea el proyecto
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package org.palomafp.aadd.jaec.config;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Configuracion {
|
||||
|
||||
private static final Properties PROPIEDADES = new Properties();
|
||||
|
||||
// Cargamos el fichero de configuracion
|
||||
static {
|
||||
try (InputStream input = new FileInputStream("config/application.properties")) {
|
||||
|
||||
PROPIEDADES.load(input);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("No se pudo cargar config/application.properties", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Metodo para obtener el valor de una propiedad
|
||||
public static String get(String clave) {
|
||||
|
||||
String valor = PROPIEDADES.getProperty(clave);
|
||||
|
||||
if (valor == null || valor.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("No existe la propiedad: " + clave);
|
||||
}
|
||||
|
||||
return valor.trim();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user