springboot启动报Description:Failed to configure a DataSource: ‘url‘ attribute is not specified and no

    科技2022-07-11  124

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

    Disconnected from the target VM, address: '127.0.0.1:54478', transport: 'socket'

     

    原因:因为依赖别的项目的pom文件导入了mybatis的数据源依赖,项目启动时会进行自动配置,而我的这个项目没有使用数据源相关操作,所以报了异常。

    解决:在启动类注解上加上 exclude = DataSourceAutoConfiguration.class

    @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

    另一个解决办法是也可以在pom文件中进行排除。

     

     

    Processed: 0.025, SQL: 8