Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Fa

Numery :

I am developing a web application by using the Spring Boot, Spring Cloud Config and Docker. There are 3 projects. One is springboot web, Spring Cloud Config Server and MySql Database. I have use the Spring Boot Web with Themeleaf. It's basically perform a CRUD operation. In the development phase it's working fine. But when I deploy it in the Docker Spring-Boot webapp container(springboot-thymeleaf-web-crud) is giving me the following error--


APPLICATION FAILED TO START


Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

I have created 3 container on Docker Compose file.

version: '3'

services: 
   springboot-thymeleaf-web-crud:
      image: numery/springboot-thymeleaf-web-crud:latest
      networks: 
         - employee-network
      ports:
         - 8080:8080 
      depends_on:
         - employee-database   
         - spring-cloud-config-server-employee

   spring-cloud-config-server-employee:
      image: numery/spring-cloud-config-server-employee:latest
      networks: 
         - employee-network
      ports:
         - 8888:8888

   employee-database:
      image: mysql:5
      networks:
         - employee-network
      environment:
         - MYSQL_ROOT_PASSWORD=rootpassword
         - MYSQL_DATABASE=employee_directory
      volumes:
         - /home/numery/Docker-Database/employee_directory:/var/lib/mysql

networks:
   employee-network:

SpringBoot Web Application.properties is given below

spring.application.name=employee-service-mysql
server.port=8080
spring.cloud.config.uri=http://spring-cloud-config-server- 
employee:8888
spring.profiles.active=dev

SpringBoot Config Server is providing the following properties--

spring.datasource.url: jdbc:mysql://employee- 
database:3306/employee_directory? 
useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
spring.datasource.username: root
spring.datasource.password: rootpassword
spring.datasource.validationQuery: SELECT 1
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.tomcat.max-wait: 20000
spring.tomcat.max-active: 50
spring.tomcat.max-idle: 20
spring.tomcat.min-idle: 15

spring.jpa.properties.hibernate.dialect: 
org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql: true
spring.jpa.format-sql: true
spring.jpa.database: MYSQL
spring.jpa.hibernate.ddl-auto: create

Out of these 3 containers Mysql and Spring Cloud Config container is working fine. But for the Spring Boot Webapp(springboot-thymeleaf-web-crud) is exiting by giving the error above.

Note: I use the same datasouce(Spring Data JPA) configuration on some other SpringBoot Rest API. Which are working fine. But this is the first time I am using SpringBoot Web. Do I need to explicitly define any configuration on the data-source.

Please help!!

Numery :

I perform the following task to solve the problem--

1) We should have up and running the mysql container.

2) Inspect mysql container which ip running-- docker inspect mysqlcontainer | grep IP

3) Add the IP of that mysql container to my springboot web app--

"spring.datasource.url: jdbc:mysql://172.20.0.2:3306/employee_directory? useSSL=false&serverTimezone =UTC&useLegacyDatetimeCode=false"

4) run mvn clean, mvn install and build the SpringBoot Web image.

5) If we down the container we need to perform the same task again. Because each time Mysql container obtain the different ip.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. SPRING

Config-Server Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

Spring Boot: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified

Failed to auto-configure a DataSource: 'spring.datasource.url'

Springboot + JSP + Spring Security: Failed to configure a DataSource

Configure DataSource programmatically in Spring Boot

Failed to configure a DataSource: 'url'

How to configure datasource in wildfly 10?

'url' attribute is not specified and no embedded datasource could be configured

Failed to configure a DataSource: Intellij Error when connecting Database to Spring Application

Properties in my application.properties file are greyed out, i get Failed to configure a DataSource: 'url' attribute is not specified

Cannot resolve this error: Failed to configure a DataSource

Gradle project --Failed to configure a DataSource'url' attribute is not specified and no embedded datasource could be configured

Spring Boot jdbc issue. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

Failed to configure a DataSource: 'url' attribute is not specified using Spring Boot

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

@Sql Failed SQL scripts: The configured DataSource [*] (named 'fooDS') is not the one associated with transaction manager [*] (named 'fooTM')

Change Datasource of a chartsheet (no embedded sheet)

Configure datasource via values

Could not find datasource in hibernate

Coldfusion 9 Datasource could not be found

SpringBoot2 Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured

Failed to configure a DataSource from command line

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.Error In Gradle project

Spring Framework: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

'url' attribute is not specified and no embedded datasource could be configured. Failed to determine a suitable driver class

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured for MongoDb

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive