Заменил используемую СУБД Postgres на MySQL

https://spring.io/guides/gs/accessing-data-mysql
This commit is contained in:
Leonid
2025-02-04 10:23:44 +03:00
parent a44391dcf7
commit 7583c00749
3 changed files with 15 additions and 18 deletions

View File

@@ -1,10 +1,11 @@
services: services:
postgres: mysql:
restart: on-failure image: 'mysql:latest'
image: postgres:13
ports:
- "5454:5432"
environment: environment:
POSTGRES_USER: user - 'MYSQL_DATABASE=sweater_db'
POSTGRES_PASSWORD: 123456 - 'MYSQL_PASSWORD=123456'
POSTGRES_DB: sweater_db - 'MYSQL_ROOT_PASSWORD=verysecret'
- 'MYSQL_USER=user'
ports:
- '3306'

View File

@@ -26,12 +26,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mustache</artifactId> <artifactId>spring-boot-starter-mustache</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>
@@ -43,7 +41,6 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -55,8 +52,8 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.postgresql</groupId> <groupId>com.mysql</groupId>
<artifactId>postgresql</artifactId> <artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -69,5 +66,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@@ -1,6 +1,6 @@
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:postgresql://localhost:5454/sweater_db spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/sweater_db
spring.datasource.username=user spring.datasource.username=user
spring.datasource.password=123456 spring.datasource.password=123456
spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql: true