wildfly: reading properties from configuration directory

前端 未结 7 1683
谎友^
谎友^ 2020-12-14 03:39

I\'m trying to read deployment specific information from a properties file in my wildfly configuration folder. I tried this:

@Singleton
@Startup
public class         


        
7条回答
  •  暖寄归人
    2020-12-14 04:18

    InputStream in = null;
    File confDir = new File(System.getProperty("jboss.server.config.dir"));
    File fileProp = new File(confDir, "my.properties");
    
    try{
        //teste fileProp.exists etc.
    
        in = new FileInputStream(fileProp);
        Properties properties = new Properties();
        properties.load(in);
    
        //You should throws or handle FileNotFoundException and IOException
    }finally{
        try{
            in.close();
        }catch(Exception ignored){
        }
    }
    

提交回复
热议问题