System.getProperty、PropConfig.loadConfig应用

1, the development of location (next to fetch items System.getProperty ( "admin.root")):

In web.xml configuration webAppRootKey

<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>aaa.root</param-value>
</context-param>

java code: System.getProperty ( "aaa.root")

You can get tomcat project directory: for example webapps \ Project

   System.getProperty ( "aaa.root") + "/ the WEB-INF / classes" just to classess directory, you can add your own path up.

Similarly jboss follows:

  System.getProperty("aaa.root");

  Get the project path (Note that this acquisition project path, if the storage file, re-conference loss; can be used to store temporary files ):

  D:\server\jboss\wildfly-8.1.0.Final\standalone\deployments\sdm-admin.war。

 2, call the properties file information:

  private static PropConfig setConfig =PropConfig.loadConfig("conf/auth/auth.properties");

  String url = setConfig.getConfigString("callbackUri");

 

Parameter callbackUri = $ [sal.callbackuri] is defined to the parent pom in:

 

Guess you like

Origin www.cnblogs.com/lojun/p/10959860.html