Home  >  Article  >  Java  >  Springboot startup error bean cannot be found, how to solve it

Springboot startup error bean cannot be found, how to solve it

王林
王林forward
2023-05-24 16:28:064465browse

    Springboot startup error reporting bean not found solution

    Error report example:

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

    Solution:

    1. It does not exist, just add it

    2. The class exists, but spring has not scanned it. Pay attention to the location of the startup class, springboot By default, the subpackages and classes in the directory where the startup class is located are scanned, as shown in Figure 1.2 below. In addition, you can use the @componentScan annotation to specify the package to be scanned: Example @componentScan ({"xxx.xx", "xxx.xx"})

    Springboot startup error bean cannot be found, how to solve it 2. Due to the bean The relationship between loading order and configuration files

    1. Please refer to the following blog post

    https://www.yisu.com/article/222850.htm

    https:// www.yisu.com/article/190698.htm

    https://www.yisu.com/article/229466.htm

    Supplement: Springboot startup error and other files have wrong versions 61.0, should be 52.0

    Error reported when starting the Springboot project

    java: Unable to access org.springframework.boot.SpringApplication

    Wrong class file: /D:/Maven/apache-maven -3.6.3/repository/org/springframework/boot/spring-boot/3.0.0/spring-boot-3.0.0.jar!/org/springframework/boot/SpringApplication.class

    Class file has wrong version 61.0, should be 52.0
    Please delete the file or make sure it is in the correct classpath subdirectory.

    Springboot startup error bean cannot be found, how to solve itReason

    SpringBoot uses 3.0 or above, because Spring's official release supports at least JDK17 starting from Spring6 and SpringBoot3.0, so only SpringBoot Just lower the version to below 3.0.

    Springboot startup error bean cannot be found, how to solve itReduce the SpringBoot version to below 3.0. The version is optional, just refresh Maven and restart.

    The above is the detailed content of Springboot startup error bean cannot be found, how to solve it. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete