首页 > 编程语言 > 详细

第一个springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

时间:2020-01-17 23:41:09      阅读:1011      评论:0      收藏:0      [点我收藏+]

 

 

报错内容具体如下

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

其中Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could be configured.

翻译就是:无法配置DataSource:未指定‘url‘属性,也无法配置嵌入数据源。

就是在应用中没有配置datasource的一些相关属性,例如:地址值,数据库驱动,用户名,密码

SpringBoot的最大一个好处就是自动配置:所以我们只是需要给他配置文件的值,它就会自动配置。配置在application.properties文件中,不过也可以不配置,但是需要声明一下

启动类头部声明就可以了:

具体操作如下

1.找到main下的Application.java文件

技术分享图片

 

2.在该文件下的

@SpringBootApplication后添加
(exclude = DataSourceAutoConfiguration.class)

如下,然后重新启动项目就可以了

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

}

第一个springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

原文:https://www.cnblogs.com/gaosimeng0627/p/12207603.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!