May 14, 2021 JFinal manual
The PropKit tool class is used to manipulate external profiles. PropKit is extremely easy to use at any time and space in the system, such as the following example code:
public class AppConfig extends JFinalConfig{
public void configConstant(Constantsme) {
The configuration loaded for the first time using the use will become the main configuration, which can be obtained through PropKit.get (...) T ake the value propKit directly. use ("a_little_config.txt");
me.setDevMode(PropKit. getBoolean ("devMode"));
}
public void configPlugin(Pluginsme) {
Non-first-time use of the use of the configuration, you need to use the use of the use each time to specify the profile name and then take the value of String redisHost . . . PropKit. use ("redis_config.txt").get("host"); i nt redisPort= PropKit. use ("redis_config.txt").getInt("port"); RedisPlugin rp = new RedisPlugin("myRedis", redisHost, redisPort); me.add(rp);
Between the first use-loaded configuration, you can also get a Prop object, which is then used to get the value Prop p -PropKit. use ("db_config.txt");
DruidPlugin dp = new DruidPlugin(p.get("jdbcUrl"), p.get("user")...); me.add(dp);
}
}
As shown in the code above, PropKit can load multiple profiles at the same time, and the first loaded profile can use PorpKit.get(...) M
ethod direct operation, non-first loaded profile needs to use PropKit.use (...). g
et(...) to operate.
PropKit is not limited to YourJFinalConfig, which can be used anywhere in the project, and JFinalConfig's getProperty method relies on the PropKit implementation at its base.