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);
    	}
    
    }
  • 相关阅读:
    Selct 大全
    Web API
    其他
    ADO.NET Entity Framework
    ORACLE SQL前端补0的三种方式。
    linux常用命令
    oracle 创建修改 job
    oracle 如何恢复误删的表记录数据
    myeclipse上SVN代码合并详细步骤图解
    SVN创建资源与分支详解
  • 原文地址:https://www.cnblogs.com/gaosimeng0627/p/12207603.html
Copyright © 2011-2022 走看看