wildfly: reading properties from configuration directory

前端 未结 7 1675
谎友^
谎友^ 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:14

    If you have in standalone.xml property:

    
    

    you can wasily read it with:

    static final String MY_PROPERTY = System.getProperty("my.properties");
    

    Or if you specify context param in web.xml like:

    
        MyProperty
        MyPropertyValue
    
    

    You can read it in Java bean:

    String myProperty= getServletContext().getInitParameter("MyProperty");
    

提交回复
热议问题