瞎几把改

master
luffy9412 7 years ago
parent b37a69803f
commit 6ee0176bd7
  1. 1
      core/src/main/java/org/pqh/core/config/HibernateConfig.java
  2. 47
      core/src/main/java/org/pqh/core/util/PropertiesUtil.java

@ -3,7 +3,6 @@ package org.pqh.core.config;
import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.pqh.core.util.PropertiesUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

@ -1,47 +0,0 @@
package org.pqh.core.util;
import java.io.BufferedInputStream;
import java.util.Properties;
/**
* Properties工具类
*/
public final class PropertiesUtil {
// protected static final Logger log = LoggerFactory.getLogger(PropertiesUtil.class);
private PropertiesUtil() {
}
/**
* 根据资源文件名和name获取对应的value如果没有对应的值将返回null
*
* @param resourceFile 资源文件名
* @param name 对应的value
* @return 对应的值
*/
public static String getValue(String resourceFile, String name) {
if (resourceFile == null || name == null) {
return null;
}
return loadPropertiesFromResourceFile(resourceFile).getProperty(name);
}
/**
* 根据资源文件路径读取资源文件如果资源文件不存在将返回默认的[new Properties()]
*
* @param resourceFile 资源文件名
* @return 资源文件
*/
public static Properties loadPropertiesFromResourceFile(String resourceFile) {
Properties properties = new Properties();
try (BufferedInputStream bis = new BufferedInputStream(
PropertiesUtil.class.getClassLoader().getResourceAsStream(resourceFile))) {
properties.load(bis);
return properties;
} catch (Exception e) {
// log.error(e.getMessage(), e);
}
return properties;
}
}
Loading…
Cancel
Save