Announcement Announcement Module
Collapse
No announcement yet.
Reading properties file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading properties file

    In my java app there is a code which reads the properties file from src/main/resources folder.

    Code:
    @Component("mailerProperties")
    public class MailerProperties {
    
    	private static Properties properties;
    	
    	public MailerProperties() {
    		properties = new Properties();
    		InputStream inStream;
    		try {
    			inStream = (new ClassPathResource("mailer.properties")).getInputStream();			
    			properties.load(inStream);
    		} catch (IOException e) {			
    			e.printStackTrace();
    		}	
    	}
    	
    	public String getValue(String key) {
    		return properties.getProperty(key);
    	}
    
    	
    }
    Now I need to create a jar file and also remove the properties file from src/main/resources folder and place it outside the jar file(in the same location as jar file) so that data inside it can be changed easily in future.

    Question: Currently it uses ClassPathResource("mailer.properties") to read the prop file. What change I need to make to read it from outside the jar file

  • #2
    http://www.summa-tech.com/blog/2009/...s-with-spring/

    http://blog.carbonfive.com/2008/04/2...s-with-spring/

    Comment

    Working...
    X