读取 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","")
原文地址:https://www.cnblogs.com/li-lun/p/12175455.html
时间: 2024-10-06 20:05:59