Skip to content

Commit

Permalink
feat/M2-7(Criar interfaces para o banco de dados) ✨ Add PostgreSQL an…
Browse files Browse the repository at this point in the history
…d spring-boot-starter-data-jpa dependencies

- **Adicione as dependências PostgreSQL e spring-boot-starter-data-jpa**
  - As dependências PostgreSQL e spring-boot-starter-data-jpa foram adicionadas no arquivo pom.xml.

- **Atualize o arquivo application.yaml**
  - O arquivo application.yaml foi atualizado com os detalhes da conexão PostgreSQL.

Estas mudanças são necessárias para:

- **Integrar um banco de dados PostgreSQL com a aplicação Spring Boot**
  - A integração com o banco de dados PostgreSQL permite à aplicação Spring Boot interagir com esse banco de dados.

- **Utilizar o Spring Data JPA para interações com o banco de dados**
  - A dependência spring-boot-starter-data-jpa facilita as interações com o banco de dados, fornecendo um conjunto de ferramentas perspicazes e fáceis de usar.

- **Crie um arquivo docker-compose**
  - Um arquivo docker-compose também foi criado para inicializar o contêiner do banco de dados PostgreSQL.
  - Lembre-se que estamos usando o modelo mais atual de Compose.
  • Loading branch information
diegosneves committed Feb 29, 2024
1 parent dd43d24 commit 96f5b53
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
15 changes: 15 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
database:
image: "postgres:latest"
container_name: hex_postgres_db
environment:
- POSTGRES_USER=local_user
- POSTGRES_DB=local_db
- POSTGRES_PASSWORD=local_password
ports:
- "5432:5432"
volumes:
- db-postgres-hex:/var/lib/postgresql/data

volumes:
db-postgres-hex:
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.2.0</version>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@Service
public class ProductService implements ProductServiceContract {

private ProductPersistenceContract persistence;
private final ProductPersistenceContract persistence;

/**
* O construtor do ProductService onde se define o repositório(permanent storage) que está sendo usado
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ server:
port: 8080

springdoc:
datasource:
url: jdbc:postgresql://localhost:5432/local_db
username: local_user
password: local_password
jpa:
hibernate:
ddl-auto: update
show-sql: true

swagger-ui:
path: /swagger-ui.html

Expand Down

0 comments on commit 96f5b53

Please sign in to comment.