static Logger logger = LoggerFactory.getLogger(LoginShiro.class);
private static String jdbcUrl; private static String jdbcUserName; private static String jdbcPassword; static{ InputStream inStream= null; try { String filePath=LoginShiro.class.getClassLoader().getResource("config/jdbc.properties").getFile(); //String configPath=LoginShiro.class.getResource("/").getPath()+"config/jdbc.properties"; FileInputStream in = new FileInputStream(filePath); Properties properties = new Properties(); properties.load(in); jdbcUrl = properties.getProperty("jdbc_url"); jdbcUserName = properties.getProperty("jdbc_username"); jdbcPassword = properties.getProperty("jdbc_password"); } catch (Exception e) { e.printStackTrace(); }finally{ if(inStream!=null){ try { inStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }