欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

springboot启动报错Failed to configure a DataSource: 'url' attribute is not specified

程序员文章站 2022-05-18 14:27:39
Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to dete ......

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

原因: 配置的注解需要连接数据库,一个解决方式是添加exclude排除,代码如下:

@springbootapplication(exclude = datasourceautoconfiguration.class)
我的是一个parent有多个子模块,子模块有两个app且都加了@springbootapplication注解,如果要正常运行两个类必须都加上exclude = datasourceautoconfiguration.class才可以

 经测试,我的是需要去掉依赖


 <dependency>
      <groupid>org.springframework.boot</groupid>
      <artifactid>spring-boot-starter-data-jpa</artifactid>
 </dependency>
手动删除它所生成的项目的jar包,重编译,然后就可以正常启动。