File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed
sample-spring-boot-echo-kotlin
src/main/kotlin/com/example/bot/spring/echo
src/main/java/com/example/bot/spring/echo Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ apply plugin: 'kotlin'
22apply plugin : ' org.springframework.boot'
33
44dependencies {
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}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import com.linecorp.bot.model.message.Message
2323import com.linecorp.bot.model.message.TextMessage
2424import com.linecorp.bot.spring.boot.annotation.EventMapping
2525import com.linecorp.bot.spring.boot.annotation.LineMessageHandler
26+ import org.slf4j.LoggerFactory
2627import org.springframework.boot.SpringApplication
2728import org.springframework.boot.autoconfigure.SpringBootApplication
2829
@@ -33,15 +34,17 @@ fun main(args: Array<String>) {
3334@SpringBootApplication
3435@LineMessageHandler
3536open 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}
Original file line number Diff line number Diff line change 1717apply plugin : ' org.springframework.boot'
1818
1919dependencies {
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}
Original file line number Diff line number Diff line change 1616
1717package com .example .bot .spring .echo ;
1818
19+ import org .slf4j .Logger ;
20+ import org .slf4j .LoggerFactory ;
1921import org .springframework .boot .SpringApplication ;
2022import org .springframework .boot .autoconfigure .SpringBootApplication ;
2123
3032@ SpringBootApplication
3133@ LineMessageHandler
3234public 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 }
You can’t perform that action at this time.
0 commit comments