first commit
This commit is contained in:
35
payment-command/build.gradle
Normal file
35
payment-command/build.gradle
Normal file
@@ -0,0 +1,35 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group = 'com.example'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
sourceCompatibility = '17'
|
||||
|
||||
configurations {
|
||||
compileOnly {
|
||||
extendsFrom annotationProcessor
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://repo.spring.io/milestone' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.kafka:spring-kafka'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
runtimeOnly 'mysql:mysql-connector-java'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.springframework.kafka:spring-kafka-test'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
14
payment-command/src/main/java/com/example/Listener.java
Normal file
14
payment-command/src/main/java/com/example/Listener.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.example;
|
||||
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Service
|
||||
public class Listener {
|
||||
@KafkaListener(topics = "topic", groupId = "group1")
|
||||
public void consume(String message) {
|
||||
System.out.println("receive message : " + message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class PaymentCommandApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PaymentCommandApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
14
payment-command/src/main/resources/application.yaml
Normal file
14
payment-command/src/main/resources/application.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
server:
|
||||
port: 8081
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/payment?serverTimezone=Asia/Seoul&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: payment
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
show-sql: true
|
||||
database-platform: org.hibernate.dialect.MySQL8Dialect
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.example.payment;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
|
||||
@SpringBootTest
|
||||
class PaymentApplicationTests {
|
||||
@Autowired
|
||||
KafkaTemplate<String, String> template;
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
template.send("topic", "hello this is new topic2!!!!!!");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user