我需要使用设置一些全局变量,这些变量将被一些类使用。
我无法从属性文件中分配静态变量。
我想如何调用变量是这样的: String url = WebdriverConfiguration.getBaseUrl();
public class WebDriverConfiguration
{
private static Properties testProperties;
private static String instaceUrl;
testProperties = loadProperties();
public static final String DEFAULT_BASEURL = testProperties.getProperty("confluence.base.url","");
private static final int DEFAULT_HTTP_PORT = 8080;
private static final String DEFAULT_CONTEXT_PATH = "/";
public static final String TEST_SPACE_KEY = "SMOKE";
public static final String TEST_PAGE = "XXX";
private static final String BASE_URL = System.getProperty("baseurl", DEFAULT_BASEURL);
public static String getBaseUrl()
{
return BASE_URL;
}
private Properties loadProperties() throws IOException
{
InputStream testPropertiesInput = getClass().getClassLoader().getResourceAsStream("webtester.properties");
Properties testProperties = new Properties();
if (null != testPropertiesInput)
{
try
{
testProperties.load(testPropertiesInput);
}
finally
{
IOUtils.closeQuietly(testPropertiesInput);
}
}
return testProperties;
}
}