properties解決中文亂碼


讀取 properties文件,解決中文亂碼
        ConfigurableEnvironment environment = context.getEnvironment();
            String env=environment.getActiveProfiles()[0];
            Properties   pro = new Properties();
            Map<String, String> mpro = new HashMap<String, String>();
            String proName ="/application-"+env+".properties";
            InputStreamReader isr=null;
            isr=new InputStreamReader( this.getClass().getResourceAsStream(proName),"UTF-8");
            pro.load(isr);
            Iterator<String> it=pro.stringPropertyNames().iterator();
            shopAppTabs= pro.getProperty("lanhu.appTab.shopAppTab");

使用apollo讀取,當前類添加@EnableApolloConfig,讀取對應namespace

 Config config = ConfigService.getConfig("RD.int-spring-qpl-shop");
config.getProperty("lanhu.appTab.shopAppTab","")


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM