デフォルトの設定値の確認をしたかったので、テストクラスを実行して確認する方法を調べました。
ConfigInspection.java
package com.example.demo.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;
import com.zaxxer.hikari.HikariConfig;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ConfigInspection {
private Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private ApplicationContext ctx;
@Test
public void test() throws Exception {
ServerProperties serverProperties = ctx.getBean(ServerProperties.class);
ServerProperties.Tomcat tomcat = serverProperties.getTomcat();
log.debug("tomcat.maxThreads: {}", tomcat.getMaxThreads());
log.debug("tomcat.maxConnections: {}", tomcat.getMaxConnections());
log.debug("tomcat.acceptCount: {}", tomcat.getAcceptCount());
ServerProperties.Servlet servlet = serverProperties.getServlet();
log.debug("servlet.contextPath: {}", servlet.getContextPath());
HikariConfig hikariConfig = ctx.getBean(HikariConfig.class);
log.debug("dataSource: {}", hikariConfig.getDataSource());
log.debug("dataSourceProperties: {}", hikariConfig.getDataSourceProperties());
log.debug("jdbcUrl: {}", hikariConfig.getJdbcUrl());
log.debug("maximumPoolSize: {}", hikariConfig.getMaximumPoolSize());
}
}