当前位置: 首页 > 知识库问答 >
问题:

Spring错误:无法确定合适的jdbc url

闽承望
2023-03-14

我正在努力学习Spring,并在YouTube上遵循一个人的指示。起初,他只初始化了Spring项目,并编写了配置,我复制并创建了名为雇员的数据库。简而言之,我和他做了完全相同的事情,但是当我试图运行程序时,我得到了这个错误:

***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine suitable jdbc URL

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).

我正在使用MySQL和JPA。这是我的配置:

spring.datasoruce.url=jdbc:mysql://localhost:3306/employeemanager
spring.datasource.username=root
spring.datasource.password=2525
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update

我在网上找到了一个解决方案:

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})而不是@SpringBootApplication

这首先解决了问题,但是,有人提到这不是一个适当的解决办法。所以我有两个问题:

>

  • 这个问题的原因是什么,我该如何解决?

    用简单的话来说,我提到的解决方案到底在做什么?

    非常感谢。

  • 共有1个答案

    赫连子石
    2023-03-14

    看来你把Spring的房子卖错了。datasoruce。url不正确。数据源的拼写不正确。你能试试Spring吗。数据源。网址。

     类似资料:
    • 实际上,我正在开发一个带有Spring引导的restful API,我使用失眠作为客户端来测试对我的实体所做的修改。使用tomcat运行应用程序时,会显示错误消息: 无法启动应用程序 说明: 配置DataSource失败:未指定url属性,无法配置嵌入式数据源。 原因:无法确定合适的驱动程序类别。 我在文件“application.properties”中进行了必要的配置,并在pom.xml文件中

    • 我正在尝试将Postgres DB连接到我的Spring Boot应用程序,但出现以下错误: 配置数据源失败:未指定“url”属性,无法配置嵌入式数据源。原因:未能确定合适的驱动类< BR>动作: 考虑如下:如果你想要一个嵌入式数据库(H2,HSQL或DeBy),请把它放在类路径上。如果要从特定配置文件加载数据库设置,则可能需要激活它(当前没有激活的配置文件)。 application.yaml

    • 启动应用程序时,出现以下错误: 上下文初始化过程中遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException:创建名为“Block DataController”的bean时出错:注入资源依赖项失败;嵌套异常为org.springframework.beans.factory.beanCreationException:创

    • 我正在使用SpringBootJPA创建一个应用程序,我正在使用MySQL作为数据库。 以下是我的申请表。性质 我添加了以下依赖项 当我签入调试日志时,我可以在我的类路径中看到mysql java连接器,但仍然会出现以下错误 2019-07-29 10:03:00.742信息10356---[主要]o.a.c.c.c.c。[雄猫]。[本地主机]。[/]:初始化Spring嵌入式WebApplica

    • 我已经有这个错误将近一个星期了,现在我正准备让步。我已经使用Maven2制作了这个大的jar文件。当我使用以下命令运行jar文件时: 我得到这个错误: JavaProjectApplicationContext.xml如下所示: 到目前为止我试过的事情。 用3种不同的方式构建项目(2个IDE和命令行)删除了所有jar依赖关系冲突(我有spring-2.5.6.jar和spring-context-

    • 从命令python setup.py egg_info完成输出:运行egg_info创建pip egg info/psycopg2.egg-info写入pip egg info/psycopg2.egg-info/PKG-info将顶级名称写入pip egg info/psycopg2.egg-info/top_level.txt写入依赖项链接到pip egg info/psycopg2.egg-