我在重新搭建个新的springboot项目的时候,想完成个springSecurity安全权限框架的时候,没有引入数据库依赖,启动程序的时候报错。
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
//无法配置数据库,没有指定url属性,并且无法配置embedded datasource
Reason: Failed to determine a suitable driver class
//原因:无法明确指定正确的驱动类(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
解决方法1:
不想链接数据库的时候,在启动类中加入这个注解就可以完美解决。
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)//排除自动配置
解决方法2:
在pom 文件中加入和数据库相关的依赖,yaml中加入和数据库相关的配置。