Table of contents
In this article, I will be discussing one of the most tedious errors I have encountered while working on a Maven Java project with spring boot. it took a while before I could puzzle it out. The error comes up whenever I add a new dependency to my pom.xml file and whenever I restart my application.
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2m2023-06-03T17:03:14.366+01:00[0;39m [31mERROR[0;39m [35m7816[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.d.LoggingFailureAnalysisReporter [0;39m [2m:[0;39m
***************************
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).
The application Failed to start
When we see errors like this, it is easy to think it is an error with the database configuration in the application. property file, and of course, it is because my console log says "If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active)." This might not be the case but the console log would point to it.
The errors are caused by adding a new dependency to the other dependencies present in the pom.xml file. Let me show you what I'm talking about in my past project.
We have a picture above showing my project folders with different dependencies in the pom.xml file. In the next image, I will remove one of the dependencies and restart the application.
Changing Port Number
In this image, I have removed the dependency on dev tools. and I will restart my application. After restarting the application, I'm getting an error from the console like this and the application refuses to start.
this error can be frustrating and delay productivity. One of the many ways to solve this is to change the port number from the application. property file let's say server.port=8080
and replace it with another port number server.port=9090
.
server port with port number 8080
server port changed to port number 9090
If we restart the application after changing the port number, we will realize that the error is gone and the application start immediately.
Conclusion
That is one of the few ways I have been able to solve errors like that. We can simply change back to the previous port 8080
when we restart the application, It will work fine that way.