If you want an embedded database (H2, HSQL or Derby), please put it on the classpath
程序员文章站
2022-04-19 22:40:36
...
Spring Boot启动过程中遇到了下列这个问题
Description:
Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.
Reason: Failed to determine suitable jdbc url
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).
主要分析
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath
这句话是说数据库不在类路径中,那么是什么导致不在类路径中,初始看到这句话也很懵,各种maven update,删除多余代码等等都不行,然后启动了另一个同git下的项目却发现可以运行,对比两个项目,剔除了业务逻辑后,共同之处无非就是引入共同的jar,然后突然想起Springboot中@SpringBootApplication只会扫描同包及其子包,而报错项目的启动类跟共同jar的包路径不同,导致无法扫描.
解决办法:一:将项目的启动类向外移,使启动类的路径既包含本项目,也包含共同jar
二:在共同jar中添加启动类,然后在项目启动类中SpringApplication.run方法中添加多个启动类,SpringApplication.run(new Class[] { MusicApp.class,CommonApp.class }, args);
推荐阅读
-
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
-
If you want an embedded database please put a supported one on the classpath
-
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath..
-
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
-
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath
-
cloud 启动报错:If you want an embedded database please put a supported one on the classpath
-
If you want an embedded database please put a supported one on the classpath
-
If you want an embedded database please put a supported one on the classpath
-
spring boot 启动报If you want an embedded database please put a supported one on the classpath
-
配置SpringCloud时错误:If you want an embedded database please put a supported one on the classpath