Skip to content

Commit

Permalink
新增了在新版本中 debug 模式的配置项和单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkfox committed Jan 2, 2021
1 parent 14dfa3e commit ec0b75a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public FenixAutoConfiguration(FenixProperties properties) {
*/
private void doConfig() {
// 获取配置值.
Boolean debug = this.properties.getDebug();
Boolean printBanner = this.properties.getPrintBanner();
Boolean printSql = this.properties.getPrintSql();
Boolean showJpaSql = this.properties.getShowJpaSql();
Expand All @@ -53,6 +54,7 @@ private void doConfig() {
// 配置常规信息、 xml 和 handler 的扫描路径.
// 如果未配置 printSql,则使用 jpa 中 show-sql 的配置值,否则使用 printSql 的值.
FenixConfigManager.getInstance().initLoad(new FenixConfig()
.setDebug(Boolean.TRUE.equals(debug))
.setPrintBanner(printBanner == null || Boolean.TRUE.equals(printBanner))
.setPrintSqlInfo(printSql == null ? Boolean.TRUE.equals(showJpaSql) : Boolean.TRUE.equals(printSql))
.setXmlLocations(CollectionUtils.isEmpty(xmlLocations) ? null : String.join(Const.COMMA, xmlLocations))
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/blinkfox/fenix/starter/FenixProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
@ConfigurationProperties("fenix")
class FenixProperties {

/**
* 是否开启 debug 模式.
*
* @since v2.4.1
*/
private Boolean debug = false;

/**
* 是否打印 Fenix 加载完配置信息后的启动 banner,默认为 true.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FenixStarterApplicationTest {
void testFenixConfig() {
// 测试常规配置.
FenixConfig fenixConfig = FenixConfigManager.getInstance().getFenixConfig();
Assertions.assertFalse(fenixConfig.isDebug());
Assertions.assertTrue(fenixConfig.isPrintBanner());
Assertions.assertFalse(fenixConfig.isPrintSqlInfo());

Expand Down

0 comments on commit ec0b75a

Please sign in to comment.