From 7583c00749dfcdb3b843d80b5a251849a302a84b Mon Sep 17 00:00:00 2001 From: Leonid Date: Tue, 4 Feb 2025 10:23:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D0=B5=D0=BC?= =?UTF-8?q?=D1=83=D1=8E=20=D0=A1=D0=A3=D0=91=D0=94=20Postgres=20=D0=BD?= =?UTF-8?q?=D0=B0=20MySQL=20https://spring.io/guides/gs/accessing-data-mys?= =?UTF-8?q?ql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compose.yml | 17 +++++++++-------- pom.xml | 8 ++------ src/main/resources/application.properties | 8 ++++---- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/compose.yml b/compose.yml index 5e3a3e5..f1b675b 100644 --- a/compose.yml +++ b/compose.yml @@ -1,10 +1,11 @@ services: - postgres: - restart: on-failure - image: postgres:13 - ports: - - "5454:5432" + mysql: + image: 'mysql:latest' environment: - POSTGRES_USER: user - POSTGRES_PASSWORD: 123456 - POSTGRES_DB: sweater_db + - 'MYSQL_DATABASE=sweater_db' + - 'MYSQL_PASSWORD=123456' + - 'MYSQL_ROOT_PASSWORD=verysecret' + - 'MYSQL_USER=user' + ports: + - '3306' + diff --git a/pom.xml b/pom.xml index 1f37af7..4635ced 100644 --- a/pom.xml +++ b/pom.xml @@ -26,12 +26,10 @@ org.springframework.boot spring-boot-starter-mustache - org.springframework.boot spring-boot-starter-web - org.springframework.boot spring-boot-devtools @@ -43,7 +41,6 @@ spring-boot-starter-test test - org.springframework.boot spring-boot-starter-data-jpa @@ -55,8 +52,8 @@ true - org.postgresql - postgresql + com.mysql + mysql-connector-j runtime @@ -69,5 +66,4 @@ - diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ca96bee..650d561 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ -spring.jpa.hibernate.ddl-auto = update -spring.datasource.url=jdbc:postgresql://localhost:5454/sweater_db +spring.jpa.hibernate.ddl-auto=update +spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/sweater_db spring.datasource.username=user spring.datasource.password=123456 -spring.datasource.driver-class-name=org.postgresql.Driver -spring.jpa.show-sql: true +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +