Skip to content

Commit

Permalink
mysql 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yudonggeun committed Sep 22, 2023
1 parent 51d75a5 commit 7a37bd8
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 20 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ dependencies {

developmentOnly 'org.springframework.boot:spring-boot-devtools'
// developmentOnly 'org.springframework.boot:spring-boot-docker-compose'
runtimeOnly 'com.h2database:h2'
testImplementation 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j' //mysql
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
Expand Down
34 changes: 32 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
services:
spring-boot:
image: chat-app
spring-boot2:
image: chat-app-v2
build:
dockerfile: ./Dockerfile
depends_on:
- broker
- redis
- db
ports:
- "8080:8080"
networks:
- default
- app-net

spring-boot1:
image: chat-app-v2
build:
dockerfile: ./Dockerfile
depends_on:
- broker
- redis
- db
ports:
- "8081:8080"
networks:
- default
- app-net

db:
image: mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 1234
MYSQL_DATABASE: app
MYSQL_USER: user
MYSQL_PASSWORD: 1234
networks:
- app-net

redis:
image: redis
networks:
- app-net
ports:
- "6379:6379"

broker:
image: broker
Expand All @@ -24,6 +53,7 @@ services:
FROM rabbitmq
RUN rabbitmq-plugins enable rabbitmq_management rabbitmq_stomp
ports:
- "5672:5672"
- "15672:15672"
networks:
- app-net
Expand Down
17 changes: 14 additions & 3 deletions src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
spring:
config:
activate:
on-profile: test
jpa:
show-sql: true
properties:
hibernate:
format_sql: true

datasource:
driverClassName: org.h2.Driver
url: jdbc:h2:mem:testdb

#logging:
# level:
# org.hibernate.SQL: DEBUG
devtools:
livereload:
enabled: true

h2:
console:
enabled: true
path: /db
18 changes: 8 additions & 10 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ spring:
username: guest
password: guest
host: broker
# host: localhost
port: 5672

redis:
# host: localhost
host: redis
port: 6379

datasource:
url: jdbc:h2:mem:testdb

h2:
console:
enabled: true
path: /db

devtools:
livereload:
enabled: true
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://db:3306/app?characterEncoding=UTF-8&serverTimezone=UTC
username: user
password: 1234

jpa:
hibernate:
ddl-auto: create-drop
deferDatasourceInitialization: true
open-in-view: false
3 changes: 1 addition & 2 deletions src/test/java/com/websocket/demo/ChatApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class ChatApplicationTests {
class ChatApplicationTests extends SpringTest{

@Test
void contextLoads() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.websocket.demo.repository;

import com.websocket.demo.SpringTest;
import com.websocket.demo.domain.Friend;
import com.websocket.demo.domain.User;
import jakarta.transaction.Transactional;
Expand All @@ -12,9 +13,8 @@

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@Transactional
class UserRepositoryTest {
class UserRepositoryTest extends SpringTest {

@Autowired
UserRepository userRepository;
Expand Down

0 comments on commit 7a37bd8

Please sign in to comment.