test.property [src/main/resource]
------------
#main
kk=directory/kk
main.wide=this/wide
----------spring
import java.io.InputStream;
import java.util.Properties;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("singleton")
public class PropertiesUtil {
private InputStream input;
private Properties properties ;
public PropertiesUtil() throws Exception{
properties=new Properties();
input = getClass().getClassLoader().getResourceAsStream(
"test.properties");
properties.load(input);
}
public String getProperty(String key){
return properties.getProperty(key);
};
}
------------
#main
kk=directory/kk
main.wide=this/wide
----------spring
import java.io.InputStream;
import java.util.Properties;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("singleton")
public class PropertiesUtil {
private InputStream input;
private Properties properties ;
public PropertiesUtil() throws Exception{
properties=new Properties();
input = getClass().getClassLoader().getResourceAsStream(
"test.properties");
properties.load(input);
}
public String getProperty(String key){
return properties.getProperty(key);
};
}
0 comments:
Post a Comment