springboot启动时报错
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded
解决方案1
:
检查application.properties/yml,看数据库配置是否出错
示例:
server.port=8080
server.servlet.context-path=/trans
#配置数据库
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/springdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=1234
解决方案2:
查看编译后的classes文件中是否有src/main/resources目录下对应的properties文件和其他文件夹(mapper)
可以看到上图里的classes文件中既没有application.properties文件也没有mapper文件夹
重新编译后:
- 若重新编译后,classes文件夹中依然没有properties文件和mapper文件夹,可以手动复制。