Failed to configure a DataSource: 'url' attribute is not specified and no embedd
Reason: Failed to determine a suitable driver class
================================
©Copyright 蕃薯耀 2020-04-24
https://www.iteye.com/blog/user/fanshuyao
一、问题描述
*************************** 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).
原因就是springboot找到数据源的配置,但配置是有的,而且是正确的,为什么提示这个错误?
二、解决方案:
其实这个问题是包(package)路径的问题
在Springboot中,会自动扫描主启动类(@SpringBootApplication)包及所有子包
package com.datasource; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) public class Demo1Application { public static void main(String[] args) { SpringApplication.run(Demo1Application.class, args); } }
当你修改了主启动类的包名时,如将com.datasource修改成com.ds,但之前的子包没有同时修改,就会出现获取不到url的问题。因为主主启动类自动扫描com.ds及其所有子包,但此时是没有子包的。
一个简单的现象就是:当类被spring纳入管理时,类右上角是有一个“S”字母的,当你修改包名后,以前受spring管理的bean就失效,导致springboot识别不了。
解决方法:
方法一:
保证类路径一致(尽量不要手动修改主启动类,如果命名不合适需要更改,就要同时修改,类路径保持一致。)。
方法二:
在主启动类,使用@Import或@ComponentScan,引入包路径不一致但需要受到springboot管理的类。
================================
©Copyright 蕃薯耀 2020-04-24
https://www.iteye.com/blog/user/fanshuyao
相关推荐
在描述中提到的“Failed to configure driver: unknown error. Failed to open driver”是一个常见的错误提示,意味着在安装或配置HAXM时遇到了问题。 Intel HAXM依赖于计算机的硬件虚拟化功能,尤其是CPU的虚拟化...
4. failed to with "configure: error: "Could not find libreadline headers or library" 错误原因:缺少libreadline头文件或库文件。 解决方法:apt-get install libreadline5-dev 5. fail with "checking for ...
错误 configure: error: could not find library containing RSA_new: 错误 configure: error: no XML parser was found: expat or libxml 2.x required 解放方法: ...
11. configure: error: Cannot find MySQL header files under /usr.Note that the MySQL client library is not bundled anymore! 解决方法: yum install mysql-devel 此错误是由于缺少 mysql-devel 库文件所...
sqlite3文件(用于解决安卓真机中sqlite3:not found的错误) http://blog.csdn.net/hust_twj/article/details/52212558
在编译parted-3.2时,报错:configure: error: libdevmapper could not be found,找到device-mapper.1.02.28,并下了下来。 这个源码藏得有点深,分享出来给大家
然而,当我们尝试编译和安装这个版本时,可能会遇到“configure: error: *** Could not find libmount”这样的错误提示,这通常是由于系统环境配置不完整或者依赖关系未满足所导致的。 首先,我们要明白“configure...
7. **错误:configure: error: mod_deflate has been requested but can not be built due to prerequisite failures** 解决方案:在CentOS上,安装`zlib-devel`和`openssl-devel`,命令分别是`yum -y install zlib...
There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on. GMP has a rich set of functions, and the functions have a regular interface.
### Apache2.4完整安装及解决configure: error: APR-util not found问题 #### 一、背景介绍 Apache HTTP Server(通常简称为Apache)是目前最流行的Web服务器软件之一,广泛应用于互联网上的各种网站和应用程序。...
开发板没有gdb,写程序老出错而且找不到问题在哪里。于是痛定思痛,决定移植一个gdb。 交叉编译器:arm-none-linux-gnueabi ...(3)./configure –host=arm-none-linux-gnueabi –prefix=$PWD/install –wi
在编译安装软件的时候,发现错误configure: error: *** A compiler with support for C++11 language features is required. 要支持C++11,必须升级到gcc4.7以上。
编译安装软件的时候,发现错误configure: error: *** A compiler with support for C++11 language features is required. 原来是gcc版本太低了,我的版本是gcc version 4.6.3 想要支持C++11,必须升级到gcc4.8...
# Provides a relative path to your source file(s). src/main/cpp/HelloNDK.cpp ) ``` 2. 在Android Studio中,启用调试模式,选择目标设备或模拟器,确保它支持JNI调试。 调试步骤: 1. 在C++代码中设置断点...
14. **错误:configure: error: mod_deflate has been requested but can not be built due to prerequisite failures** 解决:缺少zlib和openssl的开发库,执行`yum -y install zlib-devel openssl-devel`。 15. ...
(1)以glibc-2.9.tar.gz为例; tar –zxvf glibc-2.4.tar.gz;...configure: error: you must configure in a separate build directory 因此退出glibc-2.9文件夹。 #Cd ../ # glibc-2.9/configure (3)make; make install
14. If the two ISPs do not peer with each other, then when they send traffic to each other they have to send the traffic through a provider ISP (intermediary), to which they have to pay for carrying ...
proj-6.2.0 cmake windows vs2015编译包括dll lib cct.lib cs2cs.lib geod.lib geodtest.lib gie.lib gie_self_tests.lib gtest.lib pj_phi2_test.lib proj.lib proj_6_2.lib proj_angular_io_test.lib proj_...
ffmpeg -i audio1.mp3 -i audio2.mp3 -filter_complex "[0:a][1:a]amix=inputs=2[a]" -map "[a]" output.mp3 ``` FFmpeg的安装和使用涉及多方面知识,包括编译原理、多媒体处理、编码标准等。熟练掌握FFmpeg能极...
本升级包中包含openssh-8.1p1.tar.gz openssl-1.1.1b.tar.gz zlib-1.2.11.tar.gz等3个源码资源包。