Unable to deploy Spring Boot with MySQL

I am able to deploy a simple Spring Boot application on render with no issues. However, when I try to deploy a larger app with a MySQL connection I always get an error saying that my datasource URL must start with ‘jdbc’, which it does. I do have the URL in a .env file. Could that be the reason I’m unable to deploy? I have tested it both locally and with other deployment services, all of which worked fine. On Render, I have tried adding my environmental variables manually and with a .env file.
When I try to deploy, the Dockerfile is read correctly, the Spring Boot app starts, then it crashes when trying to connect to my database.

Hi there,

Spring Boot will try and connect to your database on startup, so if you are unable to connect, it will most likely prevent your application from going live after a deployment.

I currently don’t see you having set your datasource URL to a valid JDBC URL.

Regards,
Keith

My datasource URL is fine. I have tested it both locally and with other hosting services. This is what my application.properties file looks like:

spring.datasource.url=${DB_HOST}
spring.datasource.username=${DB_USER}
spring.datasource.password=${DB_PW}

spring.mvc.view.prefix=/WEB-INF/
spring.mvc.hiddenmethod.filter.enabled=true
spring.jpa.hibernate.ddl-auto=update

spring.datasource.hikari.maximumPoolSize=100
spring.datasource.hikari.maxLifetime=60000

spring.config.import=optional:file:.env[.properties]

I then have a .env file on render.
I have also tried removing environmental variables and including the URL, username, and password in the application.properties file. It didn’t make a difference.

Hi there,

How are you creating the .env file? Can you try it with setting DB_HOST as an environment variable?

Regards,

Keith
Render Support, UTC+10 :australia:

I’m not sure I understand. My .env file consists of three lines (DB_HOST, DB_USER, and DB_PW). I have also tried deploying by setting environmental variables manually (by entering each one individually without using a .env file) as well as just writing out the URL, username, and password inside of the application.properties file. Nothing has worked.

Hi there,

I checked the GitHub repo attached to your application, I don’t see a .env file existing there, so how are you creating it? You don’t have a secrets file set, nor do you have an DB_HOST environment variable set. Can you please try setting DB_HOST again, and I can check it?

Regards,

Keith
Render Support, UTC+10 :australia:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.