Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could

简介: 解决方法:配置H2数据库或者MySQL数据库,其中配置MySQL解决方法如下:1、添加 MySQL连接驱动的依赖Maven工程在pom.xml中添加
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable 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).

这是因为工程没有配置数据库。


解决方法:


配置H2数据库或者MySQL数据库,其中配置MySQL解决方法如下:


1、添加 MySQL连接驱动的依赖


Maven工程在pom.xml中添加

   <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>

gradle工程在build.gradle中添加

implementation 'mysql:mysql-connector-java'

2、在application.properties中添加MySQL数据库配置

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 
spring.datasource.url=jdbc:mysql://localhost:3306/blog?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
spring.datasource.username=用户名
spring.datasource.password=密码

也可能是你在pom中使用了连接池,但是你没有进行数据库配置

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
Java 数据库 Spring
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
554 0
|
Java Spring
成功解决Initialization failed for ‘https://start.spring.io‘ Please check URL, network and proxy settings
这篇文章提供了解决Spring Initializr网站初始化失败问题的方法,包括检查URL、网络和代理设置。
成功解决Initialization failed for ‘https://start.spring.io‘ Please check URL, network and proxy settings
|
iOS开发 MacOS Python
【Mac 系统】解决已有清华镜像但出现CondaHTTPError: HTTP 000 CONNECTION FAILED for url
在尝试使用清华镜像创建conda环境时遇到下载超时问题,通过删除原有镜像并添加针对Mac OS的清华镜像解决了该问题。
1004 3
|
Java 关系型数据库 MySQL
【已解决】SpringBoot 启动报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no emb
【已解决】SpringBoot 启动报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no emb
10614 1
|
监控 druid Java
Springboot用JUnit测试接口时报错Failed to determine a suitable driver class configure a DataSource: ‘url‘
Springboot用JUnit测试接口时报错Failed to determine a suitable driver class configure a DataSource: ‘url‘
846 0
|
前端开发 JavaScript
前端JS截取url上的参数
文章介绍了两种前端JS获取URL参数的方法:手动截取封装和使用URLSearchParams。
807 0
|
存储 JavaScript 前端开发
js原生方法,获取url上面所有参数,并返回一个对象
JavaScript函数`getUrlParameters`用于从URL中提取所有参数并返回一个键值对对象。它接收URL,分割查询字符串,解码参数对,并存储在对象中。重复参数键会被存储为数组。
|
JavaScript
js如何实现修改URL参数并不刷新页面
js如何实现修改URL参数并不刷新页面
|
安全 Java 应用服务中间件
当遇到非法 URL 参数时,如何保障网页正常打开
访问如`http://example.com?a@b=1`的链接出现400 Bad Request错误,这是因为Tomcat不允许请求目标中含有非法字符。Spring Boot 2可通过配置`server.tomcat.relaxed-query-chars`来允许特殊字符,但这样做可能引入安全风险。因此,建议在Nginx层使用`rewrite_by_lua_block`和`ngx.redirect`进行重定向,将非法字符替换为合法形式,如`http://example.com?ab=1`,同时记录日志以监控。此方案能避免直接修改后端代码,提高安全性。
1314 0
|
存储 小程序
【边做边学】uni.switchTab的目标页面获取不到url携的参数
【边做边学】uni.switchTab的目标页面获取不到url携的参数
1106 1