让Springboot启动时不连接数据库

写了个简单的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})


 
问题解决。

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