zoukankan      html  css  js  c++  java
  • 第一个springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

    报错内容具体如下

    ***************************
    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);
    	}
    
    }
  • 相关阅读:
    bzoj4010 [HNOI2015]菜肴制作
    PHP--------TP中的ajax请求
    二维数组去重
    手机号138-0013-8000格式存储
    spring4-2-bean配置-1-依赖注入
    spring4-1-Spring的简单介绍
    Result Grouping / Field Collapsing-结果分组
    vim自动补全
    vim配置-程序员【转】
    服务端程序设计和实现总结 【转】
  • 原文地址:https://www.cnblogs.com/gaosimeng0627/p/12207603.html
Copyright © 2011-2022 走看看