您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

让Springboot启动时不连接数据库

bubuko 2022/1/25 19:09:36 java 字数 1083 阅读 770 来源 http://www.bubuko.com/infolist-5-1.html

写了个简单的Springboot工程,启动时始终会报错: “If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded ...

 

写了个简单的Springboot工程,启动时始终会报错:

“If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).”

      其意思是:“如果您想要一个嵌入式数据库,请将一个受支持的数据库放到类路径中。如果要从特定概要文件加载数据库设置,则可能需要激活它(当前没有概要文件处于活动状态)。”

       也就是说,项目中没有数据库相关的配置。Springboot在启动时默认会注入数据源,但是系统中又找不到数据库的配置,因此报错。

 

解决:
如果项目确实不需要连接数据库,请在启动类中添加注解 
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

技术分享图片

 

 


 
问题解决。

 

让Springboot启动时不连接数据库

原文:https://www.cnblogs.com/panchanggui/p/14715032.html


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶