ืืคื ื ืื ืืชื ืฆืจืื: - ืืืชืงืื Docker; - ืืชืงื ืืช IntelliJ IDEA Ultimate ืืงืื ืืืชื ืืืื ื ืืืฉื 30 ืืื; - ืืชืงื ืืช ืืชืืกืฃ Docker ื- Intellij IDEA. ืืืืืื, ืืฆืจืช ืืืฉืื Spring-Boot ืขื ืืฉืืช:
@Entity
public class Person {
@Id
@Column
@GenericGenerator(name = "generator", strategy = "increment")
@GeneratedValue(generator = "generator")
Long id;
@Column
String name;
//ะบะพะฝััััะบัะพั, ะณะตััะตัั, ัะตััะตัั
}
ืืื ืืืืฉื ืืืืืจ ื-Postgres, ืืฆืข ืืช ืืฉืืืื ืืืืื: 1. ืืื ืก ืืช ืืชืืืช ืืชืื pom.xml
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.1</version>
</dependency>
2. ืืชืืงืืืช ืืฉืืจืฉ ืฉื ืืคืจืืืงื ืฆืืจ ืงืืืฅ: docker-compose.yaml (ืืฉ ืฉืืืืช ืืงืืื ืืฆืืืืื ืืืกื) ืืชืืื ื ืืฆืืื ืืช ืชืืงืืืช ืืฉืืจืฉ java-rush-docker ืชืืื ืืงืืืฅ:
version: '3'
services:
postgres:
image: 'postgres:13'
container_name: 'java-postgres'
ports:
- 5432:5432
environment:
- 'POSTGRES_USER=sa'
- 'POSTGRES_HOST_AUTH_METHOD=trust'
- 'POSTGRES_DB=java'
ืืืืชื ืฉืืจื ืขื postgres: ืืืื ืืฅ ืืจืืง, ืืชื ืฆืจืื ืืืืืฅ ืขืืื. ืืชืืชืืช IntelliJ IDEA, ืืืฉืื ืืช ืฉืืจืืชืื , ืืชืืืื ืืืฆื, ืืืืจ ืืืืฆืืข ืืืืจ ืืืืคืืข ืืขืจื ืืื: ืกืืืืก: ืืืจืืช ืชืืื ื ืืืฉื ืืืชืจ ืขืืืจ postgres:13 ืืฆืืจืช java-postgres ... 'Compose: docker-compouse.yaml ' ื ืคืจืก ืืืฆืืื. ืื ืืืืจ ืฉืืื ืืกืืจ. ืืฉืื ืืื ืืืคืืข ืืืืื ืืฉืืืื: ืื ืืืืจ ืฉืืืื ื- java-postgres ืืืฉืง ืืฉืืจืืช postgres . ืฆืจืืื ืืืืืช ืชืืื ื ืฉื postgres 13 ืืชืืงืืืช ืืชืืื ืืช . 3. ืงืืืฅ application.yaml (ืื application.properties ) ืืืื ืืืืื ืืช ืืืืืจืืช ืืืืืช:
spring:
datasource:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/postgres
username: sa
password:
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
ืขืืฉืื ืืชื ืืืื ืืืคืขืื ืืช ืคืจืืืงื Spring-Boot. 4. ืืืืจ ืชืืืืช ืืคืจืืืงื, ืืืืจ ืืช ืืืืืืจ: ืืืฅ ืขื ืืฉืื ืืช Database , ืืืฅ ืขื "+" ืืจืฉืืื ืื ืคืชืืช, ืืืจ Postgres , ืืื ืืช ืฉื ืืืฉืชืืฉ (ืฉื ืืฉืชืืฉ: sa ) โโืืฉืื ืืืฉืชืืฉ , ืืืืง ืื ืืฉ ืงืฉืจ. ืื ืืื ืชืงืื, ืืืฅ ืขื ืืื ืืืืฉืืจ . ืืืืื ืืื ืืืคืืข: ืืกื ืื ืชืื ืื ืคืจืืก ืืืืืืจ. ืื ืืชื ืจืืฆื ืืืืื ืขืื ืขื Docker: ืืืืืจ ืื , ืืฆื ืกืจืืื ืขื Docker ืืืืฉื ืืช ืื ืฉืืืฆื ืฉื. ืงืจื ืืช ืืืืจืื ืืืกืืกื ืฉื Docker. ืฉืืืจ ืืช ืคืงืืืืช ืืืืงืจ ืืืกืืกืืืช.
GO TO FULL VERSION