diff --git a/build.gradle b/build.gradle
index 2e7d2d3..0ce127c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,13 +1,13 @@
buildscript {
ext {
- springBootVersion = '1.5.9.RELEASE'
+ springBootVersion = '2.1.3.RELEASE'
versions = [
jdk : '1.8',
lombok : '1.16.8',
logback : '1.1.7', // Logging
log4j : '1.2.14',
slf4j : '1.7.21',
- springfox : '2.6.0',
+ springfox : '2.9.2',
h2 : '1.4.190'
]
}
@@ -22,8 +22,8 @@ buildscript {
}
apply plugin: 'java'
-apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
+apply plugin: 'io.spring.dependency-management'
group = 'com.torres'
version = '0.0.1-SNAPSHOT'
@@ -31,46 +31,52 @@ sourceCompatibility = 1.8
repositories {
mavenCentral()
+ maven {
+ url "https://packages.confluent.io/maven/"
+ }
}
-
dependencies {
- // SpringBoot | web
- compile "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
- testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
- compile "org.springframework.boot:spring-boot-devtools:${springBootVersion}"
+ // SpringBoot | web
+ implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
+ implementation "org.springframework.boot:spring-boot-devtools:${springBootVersion}"
+ testImplementation "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
// SpringBoot | Actuator
// - doc - /docs
// - remote shell $> ssh user@localhost -p 2000
- compile "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}"
- compile "org.springframework.boot:spring-boot-actuator-docs:${springBootVersion}"
- compile "org.springframework.boot:spring-boot-starter-remote-shell:${springBootVersion}"
+ implementation "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}"
// SpringBoot | Admin UI
- compile "de.codecentric:spring-boot-admin-server:1.4.6"
- compile "de.codecentric:spring-boot-admin-server-ui:1.4.6"
- compile 'de.codecentric:spring-boot-admin-starter-client:1.4.6'
+ implementation "de.codecentric:spring-boot-admin-server:1.4.6"
+ implementation "de.codecentric:spring-boot-admin-server-ui:1.4.6"
+ implementation 'de.codecentric:spring-boot-admin-starter-client:1.4.6'
// Thymeleaf
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
// Lombok & logging(@SLf4j)
- compile "org.projectlombok:lombok:${versions.lombok}"
+ compileOnly "org.projectlombok:lombok:${versions.lombok}"
+// annotationProcessor "org.projectlombok:lombok:${versions.lombok}"
// Swagger
- compile "io.springfox:springfox-swagger2:${versions.springfox}"
- compile "io.springfox:springfox-swagger-ui:${versions.springfox}"
+ implementation "io.springfox:springfox-swagger2:${versions.springfox}"
+ implementation "io.springfox:springfox-swagger-ui:${versions.springfox}"
// datasource - H2
- compile "com.h2database:h2:$versions.h2"
+ implementation "com.h2database:h2:$versions.h2"
// datasource - JDBC
- compile "org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}"
- compile "mysql:mysql-connector-java:5.1.38"
+ implementation "org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}"
+ implementation "mysql:mysql-connector-java:5.1.38"
// datasource - JPA
- compile "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
+ implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
+
+ //
+ implementation 'org.springframework.boot:spring-boot-starter-data-redis'
+ implementation "redis.clients:jedis:2.10.2"
+
}
// datasource - QueryDSL
@@ -82,4 +88,8 @@ task printVersion {
doLast {
println projectVersion
}
-}
\ No newline at end of file
+}
+
+task wrapper(type: Wrapper) {
+ gradleVersion = '4.4' //version required
+}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 58b4c79..dc8d73a 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Jan 16 22:19:10 KST 2018
+#Tue Sep 10 13:45:42 KST 2019
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
diff --git a/out/production/resources/application.properties b/out/production/resources/application.properties
new file mode 100644
index 0000000..5433b7d
--- /dev/null
+++ b/out/production/resources/application.properties
@@ -0,0 +1,49 @@
+# info 서버 표시 정보
+server.port= 8080
+spring.application.name= torres-springboot-template
+info.app.name= torres-springboot-template-application
+info.app.version= 0.1.0
+info.app.description= Torres SpringBoot template project
+info.developer.name= Torres Woo
+info.developer.email=torreswoo@gmail.com
+info.developer.url=https://torreswoo.github.io/
+
+# SpringBoot | Actuator
+management.security.enabled= false
+endpoints.health.sensitive= false
+endpoints.shutdown.enabled= false
+
+# SpringBoot | devtools
+spring.devtools.livereload.enabled=true
+
+# SpringBoot | remote shell
+# - usage : $> ssh user@localhost -p 2000 // $ dashboard, metrics, thread top
+management.shell.auth.simple.user.name= user
+management.shell.auth.simple.user.password= 1234
+management.shell.ssh.enabled=true
+management.shell.ssh.port=2000
+
+# SpringBoot | Admin
+# - usage : http://localhost:8080
+# - Admin Server에 등록할 URL (현재는 localhost가 Admin)
+#spring.boot.admin.url= http://localhost:8080
+#spring.boot.admin.client.enabled= true
+
+# static resoruce
+#spring.resources.static-locations=classpath:/public/,classpath:/resources/,classpath:/static/
+
+# jolokia (defalut)
+endpoints.jolokia.enabled=true
+endpoints.jolokia.path=/jolokia
+endpoints.jolokia.sensitive=false
+jolokia.config.debug= false
+#spring.datasource.jmx-enabled=true
+
+# thymeleaf (defalut)
+spring.thymeleaf.enabled=true
+spring.thymeleaf.prefix=classpath:/templates/
+spring.thymeleaf.suffix=.html
+spring.thymeleaf.mode=HTML5
+
+# logging
+logging.config=classpath:logback.groovy
\ No newline at end of file
diff --git a/out/production/resources/application.yml b/out/production/resources/application.yml
new file mode 100644
index 0000000..0153ea7
--- /dev/null
+++ b/out/production/resources/application.yml
@@ -0,0 +1,29 @@
+spring.datasource:
+ plarform: h2
+ # driverClassName: org.h2.Driver
+ # url: jdbc:h2:mem:mydb;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://mysql:3306/${MYSQL_DATABASE:application}
+ username: ${MYSQL_ROOT_USER:root}
+ password: ${MYSQL_ROOT_PASSWORD:root}
+ initialize: true # classpath:/schema.sql, import.sql, data.sql
+
+ ## Pool Info ##
+ validationQuery: SELECT 1
+ testOnBorrow: true
+ testOnReturn: false
+ maxActive: 10
+ maxIdle: 10
+ minIdle: 10
+ initialSize: 20
+ timeBetweenEvictionRunsMillis: 5000 #5 second
+ minEvictableIdleTimeMillis: 10000 #10 second
+ validationQueryTimeout: 5
+
+# DB - JPA
+spring.jpa:
+ database: MYSQL
+ show-sql: true
+ properties.hibernate.hbm2ddl.auto: update # create, update, none, validate
+ properties.hibernate.format_sql: true
+ properties.hibernate.use_sql_comments: true
diff --git a/out/production/resources/data.sql b/out/production/resources/data.sql
new file mode 100644
index 0000000..f6f50ce
--- /dev/null
+++ b/out/production/resources/data.sql
@@ -0,0 +1,15 @@
+INSERT INTO user_action_log(id, action_time, user_id) VALUES(1, '2018-01-03 10:11:37', 10021); -- 10021이 계좌개셜
+INSERT INTO user_action_log(id, action_time, user_id) VALUES(2, '2018-01-04 10:11:37', 10022); -- 10022이 계좌개셜
+INSERT INTO user_action_log(id, action_time, user_id) VALUES(3, '2018-01-04 11:12:50', 10023); -- 10023이 계좌개셜
+INSERT INTO user_action_log(id, action_time, user_id) VALUES(4, '2018-01-06 10:11:37', 10024); -- 10024이 계좌개셜
+INSERT INTO user_action_log(id, action_time, user_id) VALUES(5, '2018-01-06 18:12:50', 10023); -- 10023이 100,000원을 카카오계좌로 충전
+INSERT INTO user_action_log(id, action_time, user_id) VALUES(6, '2018-01-07 11:12:50', 10023); -- 10023가 -> 10021에게 20,000원을 송금 / 받기
+INSERT INTO user_action_log(id, action_time, user_id) VALUES(7, '2018-01-07 12:12:50', 10024); -- 10024가 200,000원을 카카오계좌로 충전
+
+
+-- 계좌계설 --------------------------------------------------------------------
+INSERT INTO service_account_log(user_action_log_id, account_number) VALUES (1, '100-111-000');
+INSERT INTO service_account_log(user_action_log_id, account_number) VALUES (2, '200-111-000');
+INSERT INTO service_account_log(user_action_log_id, account_number) VALUES (3, '300-111-000');
+INSERT INTO service_account_log(user_action_log_id, account_number) VALUES (4, '400-111-000');
+
diff --git a/out/production/resources/logback.groovy b/out/production/resources/logback.groovy
new file mode 100644
index 0000000..45b8f25
--- /dev/null
+++ b/out/production/resources/logback.groovy
@@ -0,0 +1,170 @@
+import ch.qos.logback.classic.encoder.PatternLayoutEncoder
+import ch.qos.logback.core.ConsoleAppender
+import ch.qos.logback.core.rolling.RollingFileAppender
+import ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP
+import ch.qos.logback.core.rolling.TimeBasedRollingPolicy
+import org.springframework.boot.logging.logback.ColorConverter
+import org.springframework.boot.logging.logback.LevelRemappingAppender
+import org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter
+import org.springframework.core.env.StandardEnvironment
+
+import static SpringBootConfig.*
+import static ch.qos.logback.classic.Level.*
+
+/**
+ * Spring Boot org/springframework/boot/logging/logback_test/defaults.xml -> groovy 버전
+ */
+
+_PROFILE="${env.activeProfiles}"
+_CONSOLE_LOG_PATTERN= "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${env.getProperty("PID", "")}){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex"
+_FILE_LOG_PATTERN= "%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${env.getProperty("PID", "")} --- [%t] %-40.40logger{39} : %m%n%wex"
+_FILE_LOG_DIR="./logs"
+_FILE_MAX_HISTORY=60
+_FILE_MAX_SIZE="100MB"
+
+
+//==== [START] Spring Boot 설정 시작 ====//
+
+conversionRule("clr", ColorConverter)
+conversionRule("wex", WhitespaceThrowableProxyConverter)
+
+appender("DEBUG_LEVEL_REMAPPER", LevelRemappingAppender) {
+ destinationLogger = "org.springframework.boot"
+}
+logger("org.apache.catalina.startup.DigesterFactory", ERROR)
+logger("org.apache.catalina.util.LifecycleBase", ERROR)
+logger("org.apache.coyote.http11.Http11NioProtocol", WARN)
+logger("org.apache.sshd.common.util.SecurityUtils", WARN)
+logger("org.apache.tomcat.util.net.NioSelectorPool", WARN)
+logger("org.crsh.plugin", WARN)
+logger("org.crsh.ssh", WARN)
+logger("org.eclipse.jetty.util.component.AbstractLifeCycle", ERROR)
+logger("org.hibernate.validator.internal.util.Version", WARN)
+logger("org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration", WARN)
+logger("org.springframework.boot.actuate.endpoint.jmx", null, ["DEBUG_LEVEL_REMAPPER"], false)
+logger("org.thymeleaf", null, ["DEBUG_LEVEL_REMAPPER"], false)
+
+class SpringBootConfig {
+ static env = new StandardEnvironment()
+ static {
+ println("LOG PROFILE = ${env.activeProfiles}")
+ }
+}
+
+//==== [END] Spring Boot 설정 끝 ====//
+
+
+private void createLocalConsoleAppender() {
+ def STDOUT = 'STDOUT'
+
+ PRODUCT = STDOUT
+ USER_ERROR = STDOUT
+ APP_ERROR = STDOUT
+ SLOW_LOGIC = STDOUT
+ SLOW_QUERY = STDOUT
+
+ appender(STDOUT, ConsoleAppender) {
+ encoder(PatternLayoutEncoder) {
+ pattern = _CONSOLE_LOG_PATTERN
+ }
+ }
+}
+
+private void createServerAppenders() {
+ createFileAppender(PRODUCT, _FILE_LOG_DIR, "product")
+ createFileAppender(USER_ERROR, _FILE_LOG_DIR, "user-error")
+ createFileAppender(APP_ERROR, _FILE_LOG_DIR, "app-error")
+ createFileAppender(SLOW_LOGIC, _FILE_LOG_DIR, "slow-logic")
+ createFileAppender(SLOW_QUERY, _FILE_LOG_DIR, "slow-query")
+}
+
+def createFileAppender(name, logDir, fileName) {
+ appender(name, RollingFileAppender) {
+ file = "${logDir}/${fileName}.log"
+ rollingPolicy(TimeBasedRollingPolicy) {
+ fileNamePattern = "${logDir}/backup/${fileName}-%d{yyyy-MM-dd}.%i.zip"
+ maxHistory = _FILE_MAX_HISTORY
+ timeBasedFileNamingAndTriggeringPolicy(SizeAndTimeBasedFNATP) {
+ maxFileSize = _FILE_MAX_SIZE
+ }
+ }
+ encoder(PatternLayoutEncoder) {
+ pattern = _FILE_LOG_PATTERN
+ }
+ }
+}
+
+/**
+ * 로그 환경 설정
+ */
+ROOT_LEVEL = INFO
+APP_LEVEL = DEBUG
+TRACE_LEVEL = TRACE
+QUERY_LEVEL = WARN
+HIBERNATE_SQL_LEVEL = OFF
+
+PRODUCT = 'PRODUCT'
+USER_ERROR = 'USER_ERROR'
+APP_ERROR = 'APP_ERROR'
+SLOW_LOGIC = 'SLOW_LOGIC'
+SLOW_QUERY = 'SLOW_QUERY'
+
+switch (_PROFILE){
+ case "production":
+ createServerAppenders()
+ ROOT_LEVEL = INFO
+ APP_LEVEL = INFO
+ TRACE_LEVEL = INFO
+ QUERY_LEVEL = INFO
+ HIBERNATE_SQL_LEVEL = OFF
+ break;
+ case "verify":
+ createServerAppenders()
+ QUERY_LEVEL = INFO
+ HIBERNATE_SQL_LEVEL = DEBUG
+ break;
+ case "alpha":
+ createServerAppenders()
+ ROOT_LEVEL = DEBUG
+ APP_LEVEL = DEBUG
+ TRACE_LEVEL = DEBUG
+ QUERY_LEVEL = INFO
+ HIBERNATE_SQL_LEVEL = OFF
+ break;
+ case "development":
+ createServerAppenders()
+ QUERY_LEVEL = INFO
+ HIBERNATE_SQL_LEVEL = DEBUG
+ break;
+ default: // local
+// createServerAppenders()
+ createLocalConsoleAppender()
+ QUERY_LEVEL = DEBUG
+ HIBERNATE_SQL_LEVEL = DEBUG
+ break;
+}
+
+/**
+ * 로거 설정
+ */
+root(ROOT_LEVEL, [PRODUCT])
+
+//운영 로그
+logger("com.torres", APP_LEVEL, [PRODUCT], false)
+logger("org.springframework.web.client", APP_LEVEL, [PRODUCT], false)
+
+//예외 로그
+logger("APP_ERROR", DEBUG, [APP_ERROR], false)
+logger("USER_ERROR", DEBUG, [USER_ERROR], false)
+
+//관리 로그
+logger("TRACE", TRACE_LEVEL, [PRODUCT], false)
+logger("SLOW_LOGIC", INFO, [SLOW_LOGIC], false)
+
+logger("jdbc.sqlonly", QUERY_LEVEL, [PRODUCT], false)
+logger("jdbc.sqltiming", WARN, [SLOW_QUERY], false)
+logger("jdbc.audit", OFF, [PRODUCT], false)
+logger("jdbc.resultset", OFF, [PRODUCT], false)
+logger("jdbc.resultsettable", OFF, [PRODUCT], false)
+logger("jdbc.connection", INFO, [PRODUCT], false)
+logger("org.hibernate.SQL", HIBERNATE_SQL_LEVEL, [PRODUCT], false)
diff --git a/out/production/resources/logback.xml b/out/production/resources/logback.xml
new file mode 100644
index 0000000..53785a0
--- /dev/null
+++ b/out/production/resources/logback.xml
@@ -0,0 +1,64 @@
+
+
+
+