wildfly: reading properties from configuration directory

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

    The simplest thing you can do is to run standalone.sh with a -P option referencing your properties file (you need a URL file:/path/to/my.properties, or put the file in $WILDFLY_HOME/bin).

    Then all properties from the file will be loaded as system properties.

    For injecting configuration properties into your application classes, have a look at DeltaSpike Configuration, which supports different property sources like system properties, environment variables, JNDI entries and hides the specific source from your application.

    Alternatively, to avoid setting system properties (which will be global in the sense of being visible to all applications deployed to your WildFly instance), you can also define a custom property source for DeltaSpike reading a properties file from any given location, and these properties will be local to your application.

    0 讨论(0)
提交回复
热议问题