新浪博客

urlattributeisnotspecifiedandnoembeddeddatasourcecouldbeconfigured

2022-04-14 22:07阅读:
在springboot工程启动类中,有时会出现运行启动类时失败,报错如下
urlattributeisnotspecifiedandnoembeddeddatasourcecouldbeconfigured
这是因为,我们的工程pom文件中添加了数据库的驱动依赖,而要启动的服务并没有使用到数据库的数据
urlattributeisnotspecifiedandnoembeddeddatasourcecouldbeconfigured
当如果在springboot工程中不需要加
载或者启动某些组件的话:可在启动引导类的注解@SpringBootApplication中设置 exclude 排除即可。如下:
根据百度提供的方法,在启动类注解添加一个属性。
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
urlattributeisnotspecifiedandnoembeddeddatasourcecouldbeconfigured
这种写法的意思就是屏蔽掉spring boot的自动配置数据源,让spring boot去你写的配置文件里去找你的单数据源,注意一下 这里提到的是单数据源。

我的更多文章

下载客户端阅读体验更佳

APP专享