Sunday, November 5, 2023

spring: 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,


 >PROBLEM

Starting the application, it fails returning the following message:


***************************

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 (the profiles dev are currently active).




>SOLUTION


Cause:

Error on the scanBasePackages configuration that points to a wrong package.


wrong:
@SpringBootApplication(scanBasePackages={"com.drillback"})


package com.mongolib.ws;
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication(scanBasePackages={"com.drillback"})
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}



Fix:

@SpringBootApplication(scanBasePackages={"com.mongolib"})


package com.mongolib.ws;

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages={"com.mongosvc"})
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}



>ENV

Spring 2.x

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...