1. 程式人生 > >讀取properties檔案內容

讀取properties檔案內容

               import org.springframework.core.io.ClassPathResource;

               import java.util.Properties;

              import org.springframework.core.io.support.PropertiesLoaderUtils;

              import org.springframework.core.io.Resource;

         Resource resource = new ClassPathResource("/xx.properties");//檔案在和src同級的conf資料夾中                     Properties props = PropertiesLoaderUtils.loadProperties(resource);                                          String dbsandBoxName=props.getProperty("properties檔案中的key值");