目录
(1) 看报错信息我认为时url写错了,然后我就先排查自己的配置文件、依赖导入发现都没有问题。
(2)接下来我认为可能是springboot自动装配的dataSource没有读取到url,所以我重写了dataSouce,发现还是报错
(3)最后我以为是idea的问题准备打包用命令行的形式运行。然后我就发现了子工程打的是pom包,然后我就删除pom就解决问题了
报错:
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).
Process finished with exit code 1
解决方法:
删除子项目中的<packaging>pom</packaging>
分析:
问题分析:
(1) 看报错信息我认为时url写错了,然后我就先排查自己的配置文件、依赖导入发现都没有问题。
(2)接下来我认为可能是springboot自动装配的dataSource没有读取到url,所以我重写了dataSouce,发现还是报错
[1]在启动类上加上@PropertySource("jdbc.properties")和@Import({JdbcConfig.class)
[2]编写jdbc.properties文件
[3]编写JdbcConfig类
(3)最后我以为是idea的问题准备打包用命令行的形式运行。然后我就发现了子工程打的是pom包,然后我就删除<packaging>pom</packaging>就解决问题了
在这里我分析一下为啥么打pom包报错的原因:我们知道maven打包方式有pom、war、jar包这里有问题的小伙伴可以去这个链接看看(42条消息) maven的三种项目打包方式----jar,war,pom_赵宪福的博客-CSDN博客,<packaging>pom</packaging>
的意思是项目里没有java代码,也不执行任何代码,只是为了聚合工程或传递依赖用的。所以并不会寻找配置文件。