Skip to content

Instantly share code, notes, and snippets.

@andersoninthecode
Last active October 7, 2025 13:45
Show Gist options
  • Select an option

  • Save andersoninthecode/0cd8c05c642a9e19cefc686699b9d8b2 to your computer and use it in GitHub Desktop.

Select an option

Save andersoninthecode/0cd8c05c642a9e19cefc686699b9d8b2 to your computer and use it in GitHub Desktop.
Configurando o postgres no Sprint Boot

Configurando o Postgres no Spring Boot

Docker Compose

services:
  postgres-db:
    image: postgres:17-alpine
    restart: always
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      MAX_CONNECTIONS: 300
    volumes:
      - postgres_db:/var/lib/postgresql/data
    ports:
      - "5442:5432"
    networks:
      - alpha-net

volumes:
  postgres_db:

networks:
  alpha-net:
    driver: bridge

Application Properties

#POSTGRES
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.driver-class-name=org.postgresql.Driver

#JPA
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
spring.jpa.show-sql=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment