I’m working on a Spring Boot application and I’d like to use Supabase database as my database.
I’ve successfully set up Supabase and created a project, but I’m having trouble configuring it in my Spring Boot application, and also trouble with an endpoint of mine.
3.2.5Added the necessary PostgreSQL dependencies to my pom.xml:
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId></dependency>
Configured my application.properties with the details provided by Supabase:
spring.datasource.url=jdbc:postgresql://<supabase-host>:5432/<database-name> spring.datasource.username=<supabase-user> spring.datasource.password=<supabase-password> spring.datasource.driver-class-name=org.postgresql.Driver
I’m not sure if this configuration is sufficient or if there are additional settings required to fully integrate Supabase with Spring Boot.
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url={YOUR JDBC URL}&password={YOUR SUPABASE DB PASSWORD}
spring.datasource.username={Your DB User Name From Supabase}
spring.datasource.password={Your DB Password From Supabase}
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none
You need to get the JDBC connection String from connect --> Type --> JDBC and scroll to Session Pooler to get the JDBC URL and credentials.
For step by step process please see my blog below:https://medium.com/@khan.abdulwasey99/step-by-step-process-on-how-to-connect-a-spring-boot-application-to-supabase-f1791e1d2402
Re-posting I was not aware of Stackoverflow guidelines for external blogs.
You can do something like that :
# Supabase configuration
supabase.url=${SUPABASE_URL}
supabase.anon=${SUPABASE_ANON_KEY}
supabase.jwt_secret=${SUPABASE_JWT_SIGNER}
# Spring application configuration
spring.application.name=Demo
spring.main.banner-mode=off
# Spring datasource configuration
spring.datasource.url=${SUPABASE_DATABASE_URL}
spring.datasource.username=${SUPABASE_DATABASE_USER}
spring.datasource.password=${SUPABASE_DATABASE_PASSWORD}
spring.datasource.driverClassName=org.postgresql.Driver
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With