To create jar to build docker container for my spring boot applicaton, I run Maven Install from eclipse but build fails with below error:
2020-07-18 20:47:52.452 INFO 5920 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-07-18 20:47:52.566 INFO 5920 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-07-18 20:48:22.960 INFO 5920 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-07-18 20:48:23.299 INFO 5920 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.4.9.Final}
2020-07-18 20:48:23.821 INFO 5920 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-07-18 20:48:54.341 WARN 5920 --- [ restartedMain] o.h.e.j.e.i.JdbcEnvironmentInitiator : HHH000342: Could not obtain connection to query metadata : HikariPool-1 - Connection is not available, request timed out after 30000ms.
2020-07-18 20:48:54.361 WARN 5920 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2020-07-18 20:48:54.365 INFO 5920 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-07-18 20:49:03.446 INFO 5920 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-07-18 20:49:03.452 INFO 5920 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-07-18 20:49:03.522 INFO 5920 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-18 20:49:03.551 ERROR 5920 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
My application.properties file for spring boot application is:
spring.datasource.username=root
spring.datasource.password=ayush123
spring.datasource.url=jdbc:mysql://mysqldb:3306/employeedb
spring.datasource.platform=mysql
hibernate.hbm2ddl.auto=update
spring.jpa.generate-ddl=true
spring.datasource.hikari.initializationFailTimeout=-1
I have also tried with spring.datasource.url=jdbc:mysql://mysqldb/employeedb
I created docker network and built MYSQL container using below command:
docker pull mysql:8.0
docker network create edrms-net
docker container run --name mysqldb --network edrms-net -e MYSQL_ROOT_PASSWORD=ayush123 -e MYSQL_DATABASE=employeedb -d mysql:8.0
Upon docker container ls
,I can see MYSQL contaner deployed and running.
I am completely lost and cannot recover. Please help!
To connect to mySql server inside docker container you must publish port when running that container on which you want to connect to the server.
To achieve that add --publish 3306:3306
to your docker container run command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.