ankur bansal
ankur bansal

Reputation: 119

Getting Dialect missing error while trying to dockerize a spring boot mysql based POC

I am trying to create a Docker container for a spring boot mysql based application as part of a poc. While running docker compose up command, mysql container is coming up but the application service container is failing with below error.

Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'javax.persistence.jdbc.url', 'hibernate.connection.url', or 'hibernate.dialect')

Below are the configuration used. application.properties

    spring.datasource.url=jdbc:mysql://mysqldb:3306/product_feed?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false
        spring.datasource.username=root
        spring.datasource.password=r
        spring.datasource.initialization-mode=always
        spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
        spring.jpa.show-sql=true
        spring.jpa.hibernate.ddl-auto=update
      
 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect

I have tried to comment out spring.jpa.properties.hibernate.dialect and spring.datasource.driver-class-name but it still fails to start.

dockerfile

FROM eclipse-temurin:17-jdk-jammy

ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} product-feed.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/product-feed.jar"]

docker-compose.yml

version: "3.2"
services:
  mysqldb:
    image: mysql:8
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=r
      - MYSQL_DATABASE=product_feed
    ports:
      - "3306:3306"

  product-feed:
    image: product-feed
    ports:
      - "8080:8080"
    networks:
      - product_feed_net
    depends_on:
      - mysqldb

networks:
  product_feed_net:

The application is running fine in local.

Upvotes: 0

Views: 1942

Answers (1)

I had the same issue. After adjusting the application.properties file did you generated a new image? If yes, try removing the image from your local docker so it needs to pull it again downloading the new one adjusted

Upvotes: 1

Related Questions