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