Skip to content

Commit 570ad46

Browse files
okuekazuki-ma
authored andcommitted
NON-ISSUE Refactoring sample-spring-boot (#409)
* use logger * remove compile * use org.slf4j.LoggerFactory
1 parent 696b0b9 commit 570ad46

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

sample-spring-boot-echo-kotlin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ apply plugin: 'kotlin'
22
apply plugin: 'org.springframework.boot'
33

44
dependencies {
5-
compile project(':line-bot-spring-boot')
6-
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
5+
implementation project(':line-bot-spring-boot')
6+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
77
}

sample-spring-boot-echo-kotlin/src/main/kotlin/com/example/bot/spring/echo/EchoApplication.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.linecorp.bot.model.message.Message
2323
import com.linecorp.bot.model.message.TextMessage
2424
import com.linecorp.bot.spring.boot.annotation.EventMapping
2525
import com.linecorp.bot.spring.boot.annotation.LineMessageHandler
26+
import org.slf4j.LoggerFactory
2627
import org.springframework.boot.SpringApplication
2728
import org.springframework.boot.autoconfigure.SpringBootApplication
2829

@@ -33,15 +34,17 @@ fun main(args: Array<String>) {
3334
@SpringBootApplication
3435
@LineMessageHandler
3536
open class EchoApplication {
37+
private val log = LoggerFactory.getLogger(EchoApplication::class.java)
38+
3639
@EventMapping
3740
fun handleTextMessageEvent(event: MessageEvent<TextMessageContent>): Message {
38-
println("event: $event")
41+
log.info("event: $event")
3942
val originalMessageText = event.message.text
4043
return TextMessage(originalMessageText)
4144
}
4245

4346
@EventMapping
4447
fun handleDefaultMessageEvent(event: Event) {
45-
println("event: $event")
48+
log.info("event: $event")
4649
}
4750
}

sample-spring-boot-echo/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
apply plugin: 'org.springframework.boot'
1818

1919
dependencies {
20-
compile project(':line-bot-spring-boot')
20+
implementation project(':line-bot-spring-boot')
2121

2222
testImplementation "org.springframework.boot:spring-boot-starter-test"
2323
}

sample-spring-boot-echo/src/main/java/com/example/bot/spring/echo/EchoApplication.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.example.bot.spring.echo;
1818

19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
1921
import org.springframework.boot.SpringApplication;
2022
import org.springframework.boot.autoconfigure.SpringBootApplication;
2123

@@ -30,13 +32,15 @@
3032
@SpringBootApplication
3133
@LineMessageHandler
3234
public class EchoApplication {
35+
private final Logger log = LoggerFactory.getLogger(EchoApplication.class);
36+
3337
public static void main(String[] args) {
3438
SpringApplication.run(EchoApplication.class, args);
3539
}
3640

3741
@EventMapping
3842
public Message handleTextMessageEvent(MessageEvent<TextMessageContent> event) {
39-
System.out.println("event: " + event);
43+
log.info("event: " + event);
4044
final String originalMessageText = event.getMessage().getText();
4145
return new TextMessage(originalMessageText);
4246
}

0 commit comments

Comments
 (0)