JFast应用系列之(二) - 配置文件说明
JFast应用系列之(2) -- 配置文件说明
jfast 配置文件固定为:jfast-config.xml,位置必须是src或者src/main/java根目录下。
1.jfast默认的配置属性:
<?xml version="1.0" encoding="UTF-8"?> <context xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="jfast-context.xsd"> <jdbc jdbc_user="数据库连接用户名" jdbc_password="数据库连接密码" jdbc_url="数据库连接地址" jdbc_driver="数据库驱动" max_pool_size="连接池保有最大连接数" min_pool_size="连接池保有最小连接数" initial_pool_size="初始化连接池大小" max_idle_time="最大等待时间" acquire_increment="每次增加的连接数"/> <web develop_mode="开发模式" encoding="项目编码" cors_mode="是否支持跨域"/> <resources location="/请求静态资源路径" mapping="/实际访问静态资源路径"/> </context>注意 : JFast支持c3p0,dbcp,druid数据源,但是数据源不需要在配置文件中显性配置,只需要把相应的jar 放到项目的编译路径下,让jfast可以找到它;
在<resources/>标签中:
- location 是客户端向服务端请求静态资源的路径;
- mapping 是服务端收到请求后,跳转到的资源路径,服务端在mapping路径下寻找对应资源。
2.自定义配置属性
一般情况下,只需要使用默认的这些配置参数,就足以支撑jfast正常运行,但是为了满足不同业务需 求,jfast还支持自定义配置属性。比如 : 用户自定义配置类:
@Config public class Constants { public static String configTest1 = ""; public static String configTest2 = ""; }
在jfast-config.xml 添加 自定义配置属性(标签名随意):
<config configTest1="hello" configTest2="world"/>
项目启动后 : jfast会把配置文件中自定义属性赋值到@config注解的类的静态属性上去。