惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
S
Securelist
P
Proofpoint News Feed
D
DataBreaches.Net
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Project Zero
Project Zero
A
About on SuperTechFans
罗磊的独立博客
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
AI
AI
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security
T
Tor Project blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MyScale Blog
MyScale Blog
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
B
Blog RSS Feed
博客园 - 叶小钗
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Simon Willison's Weblog
Simon Willison's Weblog
C
CERT Recently Published Vulnerability Notes
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic

博客园 - Neonuu

解决ollama官方下载过慢的问题(包含windows和linux) 使用java 命令运行包含main方法的class文件时,报 Error: Could not find or load main class Test Java8 list.stream()常用方法 IDEA整合SVN VUE,编辑详情时,列表数据也跟着改变 VUE二级联动,改变一级下拉框,清空二级下拉框 MySQL面试题 JVM原理 Linux服务器安装MariaDB数据库 jar包解压后,修改完配置文件,再还原成jar包 Java中synchronized,wait(),notify() Java中Runnable和Thread的区别(网上部分说法是错误的) Java中如何实现一个接口拥有多个实现类 JPA中getOne与findOne try catch与spring的事务回滚 Spring主动触发事务回滚 Redis五种数据类型及应用场景 Java面试题 SQL HAVING用法详解 const,var,let区别
Java获取resources文件夹下properties配置文件
Neonuu · 2021-09-28 · via 博客园 - Neonuu

1、config.properties文件

#解析脱敏开关。0:关闭。不进行解析脱敏,返回原数据。1:开启。进行解析脱敏,返回处理后的数据。
analysisSwitch=0

2、工具类

package com.ghca.dbproxy.util;

import java.io.IOException;
import java.util.Properties;
import org.springframework.core.io.support.PropertiesLoaderUtils;

/**
 * Author:ZhaoShuang
 * Date:2021/9/27
 * Description:读取配置文件工具类
 */
public class PropertyUtil {

    /**
     * 读取配置文件中的属性值
     * @param file 文件名
     * @param property 属性名
     * @return
     */
    public static String read(String file,String property){
        Properties props = new Properties();
        try {
            props = PropertiesLoaderUtils.loadAllProperties(file);
            String value = props.getProperty(property);
            return value;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }

    public static void main(String[] args) {
        String s = read("config.properties","analysisSwitch");
        System.out.println(s);
    }
}

posted on 2021-09-28 10:28  Neonuu  阅读(356)  评论()    收藏  举报