1 package cn.rocker.readProperties; 2 3 import java.util.ResourceBundle; 4 5 import org.junit.Test; 6 7 /** 8 * @ClassName: ResourceBundleRead 9 * @Description: ResourceBundle读取配置文件 10 * @author 112 11 * @date 2018年3月28日 下午12:35:27 12 */ 13 public class ResourceBundleRead { 14 @Test 15 //读取包路径下的properties文件 16 public void readPropertiesInPackage(){ 17 ResourceBundle resourceBundle = ResourceBundle.getBundle("cn/rocker/readProperties/test/properties/cas"); 18 String url = resourceBundle.getString("SSOLogin_URL"); 19 System.out.println(url); 20 //输出:http://202.106.121.34:8888/scp/ssologin 21 } 22 23 24 @Test 25 //读取classes路径下的properties文件 26 public void readPropertiesInClasses(){ 27 ResourceBundle resourceBundle = ResourceBundle.getBundle("cas"); 28 String url = resourceBundle.getString("UnifyUserManager_URL"); 29 System.out.println(url); 30 //输出:http://139.199.20:8080/sso/UnifyUserManager 31 } 32 }