DataSource: ‘url‘ attribute is not specified and no embedded datasource coul】"/>
【Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource coul】
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could 项目启动报错后总结的分析方法
- 在Spring Boot 项目刚搭建好时启动出现标题上描述的报错。
- 问题分析方法:
在Spring Boot 项目刚搭建好时启动出现标题上描述的报错。
问题分析方法:
- 先判断是否是数据库连接配置出错;在启动类的@SpringBootApplication注解后加上(exclude= {DataSourceAutoConfiguration.class})断开与数据库的连接操作,测试是否可以正常启动。
- 再次启动项目依然报错!再检查数据库连接是否有误。
- 如果确定连接没问题就去看mybatis or mybatis-plus 在pom中导入的是否正确。以及在application.yml里是否对其做了配置
本次项目(2022-8-22)用了mybatis-plus。只用导以下依赖就可以
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.0.3</version> </dependency>
application.yml中配置如下
mybatis-plus:mapper-locations: classpath*:/mapper/**/*.xml#实体扫描,多个package用逗号或者分号分隔typeAliasesPackage: com.lineAlgorithm.lineAlgorithm.entryglobal-config:#数据库相关配置db-config:#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"field-strategy: NOT_NULL# logic-delete-value: -1# logic-not-delete-value: 0banner: false#原生配置configuration:map-underscore-to-camel-case: truecache-enabled: falsecall-setters-on-nulls: truejdbc-type-for-null: 'null'
更多推荐
【Failed to configure a DataSource: ‘url‘ attribute is not specified and no embed
发布评论