|
| 1 | +<link rel="stylesheet" href="http://yandex.st/highlightjs/6.2/styles/googlecode.min.css"> |
| 2 | + |
| 3 | +<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> |
| 4 | +<script src="http://yandex.st/highlightjs/6.2/highlight.min.js"></script> |
| 5 | + |
| 6 | +<script>hljs.initHighlightingOnLoad();</script> |
| 7 | + |
| 8 | + |
| 9 | +<script type="text/javascript"> |
| 10 | + $(document).ready(function(){ |
| 11 | + $("h2,h3,h4,h5,h6").each(function(i,item){ |
| 12 | + $(item).attr("id","wow"+i); |
| 13 | + $("#category").append("<li><a href=\"#wow"+i+"\">"+$(this).text()+"</a></li>"); |
| 14 | + }); |
| 15 | + }); |
| 16 | +</script> |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +<style> |
| 21 | +pre code { |
| 22 | + break-word: break-all; |
| 23 | + word-wrap: break-word; |
| 24 | +} |
| 25 | +</style> |
| 26 | + |
| 27 | +#ServiceFramework Wiki |
| 28 | + |
| 29 | +### 配置文件 |
| 30 | + |
| 31 | +ServiceFramework 所有的配置文件位于config目录下。其实只有两个配置文件,一个application.yml, |
| 32 | +一个logging.yml.分别配置应用和日志。 |
| 33 | + |
| 34 | +一个完整的application.yml |
| 35 | + |
| 36 | +``` |
| 37 | +#mode |
| 38 | +mode: |
| 39 | + development |
| 40 | +#mode=production |
| 41 | +
|
| 42 | +###############datasource config################## |
| 43 | +#mysql,mongodb,redis等数据源配置方式 |
| 44 | +development: |
| 45 | + datasources: |
| 46 | + mysql: |
| 47 | + host: 127.0.0.1 |
| 48 | + port: 3306 |
| 49 | + database: tag_engine |
| 50 | + username: tag |
| 51 | + password: tag |
| 52 | + disable: true |
| 53 | + mongodb: |
| 54 | + host: 127.0.0.1 |
| 55 | + port: 27017 |
| 56 | + database: tag_engine |
| 57 | + redis: |
| 58 | + host: 127.0.0.1 |
| 59 | + port: 6379 |
| 60 | +
|
| 61 | +production: |
| 62 | + datasources: |
| 63 | + mysql: |
| 64 | + host: 127.0.0.1 |
| 65 | + port: 3306 |
| 66 | + database: tag_engine |
| 67 | + username: tag |
| 68 | + password: tag |
| 69 | + mongodb: |
| 70 | + host: 127.0.0.1 |
| 71 | + port: 27017 |
| 72 | + database: tag_engine |
| 73 | + redis: |
| 74 | + host: 127.0.0.1 |
| 75 | + port: 6379 |
| 76 | +
|
| 77 | +orm: |
| 78 | + show_sql: true |
| 79 | + pool_min_size: 5 |
| 80 | + pool_max_size: 10 |
| 81 | + timeout: 300 |
| 82 | + max_statements: 50 |
| 83 | + idle_test_period: 3000 |
| 84 | +###############application config################## |
| 85 | +application: |
| 86 | + controller: com.example.controller |
| 87 | + model: com.example.model |
| 88 | + service: com.example.service |
| 89 | + util: com.example.util |
| 90 | + test: test.com.example |
| 91 | +
|
| 92 | +
|
| 93 | +###############http config################## |
| 94 | +http: |
| 95 | + port: 9400 |
| 96 | +
|
| 97 | +
|
| 98 | +
|
| 99 | +###############validator config################## |
| 100 | +#如果需要添加验证器,只要配置好类全名即可 |
| 101 | +#替换验证器实现,则替换相应的类名即可 |
| 102 | +#warning: 自定义验证器实现需要线程安全 |
| 103 | +
|
| 104 | +validator: |
| 105 | + format: net.csdn.validate.impl.Format |
| 106 | + numericality: net.csdn.validate.impl.Numericality |
| 107 | + presence: net.csdn.validate.impl.Presence |
| 108 | + uniqueness: net.csdn.validate.impl.Uniqueness |
| 109 | + length: net.csdn.validate.impl.Length |
| 110 | + associated: net.csdn.validate.impl.Associated |
| 111 | +
|
| 112 | +################ 数据库类型映射 #################### |
| 113 | +type_mapping: net.csdn.jpa.type.impl.MysqlType |
| 114 | +
|
| 115 | +``` |
| 116 | + |
| 117 | +对于数据库等的配置默认区分开发,生产,测试。单元测试强制使用测试环境。 |
| 118 | + |
| 119 | +除了默认的的一些配置,你可以随意按标准的yaml格式添加配置,在实际代码中,你可以通过下面的方式获取 |
| 120 | +配置 |
| 121 | + |
| 122 | +首先注入Settings类 |
| 123 | + |
| 124 | + @Inject |
| 125 | + private Settings settings; |
| 126 | + |
| 127 | +然后就可以如下使用了: |
| 128 | + |
| 129 | + boolean enable = settings.getAsBoolean("foo.bar.yes",false) |
| 130 | + |
| 131 | + |
| 132 | +在ServiceFramework中,Controller,Service,Util,Model等是需要在配置文件中明确指定的。类似配置如下: |
| 133 | + |
| 134 | + application: |
| 135 | + controller: com.example.controller |
| 136 | + model: com.example.model |
| 137 | + service: com.example.service |
| 138 | + util: com.example.util |
| 139 | + test: test.com.example |
| 140 | + |
| 141 | + |
| 142 | +理论上,ServiceFramework的配置就是数据库配置类的扫描路径配置。 |
| 143 | + |
| 144 | + |
0 commit comments