0

I have the project in Intellij with gradle. This is the application.properties file.

security.basic.enabled=false

spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/pai
spring.datasource.username=pai
spring.datasource.password=kasztan

This is application.yml.

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/pai
    pooled: true
    driverClassName: com.mysql.jdbc.Driver
    dialect: org.hibernate.dialect.Dialect
    username: pai
    password: kasztan
    platform: mysql
    initialize: false
  jpa:
    database-platform: org.hibernate.dialect.Dialect

This is Dockerfile.

FROM openjdk:8-jdk-alpine
VOLUME /tmp
ENV JAVA_OPTS=""
COPY gs-spring-boot-docker-0.1.0.jar /home/app.jar

EXPOSE 8080
CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /home/app.jar

The docker image has been built successfuly. When I run image using ID of image at the end I get the following error.

2018-03-18 10:46:27.155 ERROR 6 --- [ost-startStop-1] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

What can be the problem?

maciejka
  • 818
  • 2
  • 17
  • 42
  • Your `application.yml` has invalid spring.datasource.* properties. Clean it up, see https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html for a list of valid properties. – Karol Dowbecki Mar 18 '18 at 12:10
  • Possible duplicate of [com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure](https://stackoverflow.com/questions/2983248/com-mysql-jdbc-exceptions-jdbc4-communicationsexception-communications-link-fai) – Karol Dowbecki Mar 18 '18 at 12:12
  • 2
    When running in container, `localhost` will refer to the container. Since your database is running on the host, this will not work. – Strelok Mar 19 '18 at 04:54

0 Answers0