first commit

This commit is contained in:
appleg
2022-03-13 17:47:11 +09:00
commit 94e0f571e9
17 changed files with 591 additions and 0 deletions

View 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()
}

View 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);
}
}

View File

@@ -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);
}
}

View 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

View File

@@ -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!!!!!!");
}
}