标签:最大 led imp please static art 没有 启动报错 一个
报错内容具体如下
*************************** 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); } }
标签:最大 led imp please static art 没有 启动报错 一个
原文地址:https://www.cnblogs.com/gaosimeng0627/p/12207603.html