Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the error problem of starting springboot application because the database is not configured?

Shulou Source: shulou.com Published: 2022-06-02 13:21:08 11月15日 Update

This article mainly explains "how to solve the error problem of starting springboot application because the database is not configured". The explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the error problem of starting springboot application due to unconfigured database".

Start the springboot application because the database is not configured for error description

Create a brand new springboot project and start the Times error for the first time. The specific error message is as follows:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2021-06-14 17 o.s.b.d.LoggingFailureAnalysisReporter 58 o.s.b.d.LoggingFailureAnalysisReporter 10.322 ERROR 12292-[main]:

* *

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).

Process finished with exit code 1

Solution

Option one

Add database configuration information to the application.properties configuration file

Spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.datasource.url=jdbc:mysql://localhost:3306/guli?serverTimezone=GMT%2B8spring.datasource.username=cxspring.datasource.password=123456

Option 2

Declare in the startup class header declaration:

@ SpringBootApplication (exclude = DataSourceAutoConfiguration.class) springboot 1.5.8.RELEASE version startup error cause

The new spring boot project generates the project after selecting the 1.5.8.RELEASE version, and starts the project after configuring the application.properties. An error is reported.

Caused by: java.lang.ClassNotFoundException: org.springframework.core.env.EnvironmentCapable

At java.net.URLClassLoader.findClass (Unknown Source)

At java.lang.ClassLoader.loadClass (Unknown Source)

At sun.misc.Launcher$AppClassLoader.loadClass (Unknown Source)

At java.lang.ClassLoader.loadClass (Unknown Source)

Error troubleshooting

After searching by 1.ctrl+shift+t, we found that there was no such class.

two。 From the full name of this class, it can not be found that this class belongs to spring-core.jar.

3. The version of spring-core in maven dependencies is 4.3.12.RELEASE.

4. Online query shows that there is no such class in spring-core4.3.12.RELEASE.

Solution method

Find the spring-core version with this class. I use 4.3.9.RELEASE. Then add in the dependencies

Org.springframework spring-core 4.3.9.RELEASE thank you for your reading, the above is the content of "how to solve the problem of starting springboot application because the database is not configured". After the study of this article, I believe you have a deeper understanding of how to solve the problem of starting springboot application because the database is not configured, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Configuration data database problem application version project scheme learning information content error full name brand new postnatal header that is ideas situations files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info MySQL Redmi MariaDB