无法配置数据源:未指定'url'属性,并且无法配置任何嵌入式数据源

编程入门 行业动态 更新时间:2024-10-28 09:21:49
本文介绍了无法配置数据源:未指定'url'属性,并且无法配置任何嵌入式数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用MongoDB处理 Spring Boot Batch 示例,并且我已经启动了mongod服务器.

I am working on a Spring Boot Batch example with MongoDB and I have already started the mongod server.

启动应用程序时,出现以下错误.

When I launch my application, I am getting the error below.

这个问题有什么指针吗?

Any pointers for this issue?

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

application.properties:

# Mongo database URI. Cannot be set with host, port and credentials. spring.data.mongodb.uri=mongodb://localhost/test

pom.xml

<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-batch</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies>

我已经开始mongod并显示以下输出:

I have started mongod with the following output:

C:\Users\pc>mongod 2018-07-07T14:39:39.223+0530 I JOURNAL [initandlisten] journal dir=C:\data\db\journal 2018-07-07T14:39:39.230+0530 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed 2018-07-07T14:39:39.478+0530 I JOURNAL [durability] Durability thread started 2018-07-07T14:39:39.589+0530 I CONTROL [initandlisten] MongoDB starting : pid=11992 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-NQ639DU 2018-07-07T14:39:39.589+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2 2018-07-07T14:39:39.591+0530 I CONTROL [initandlisten] db version v3.0.5 2018-07-07T14:39:39.592+0530 I CONTROL [initandlisten] git version: 8bc4ae20708dbb493cb09338d9e7be6698e4a3a3 2018-07-07T14:39:39.592+0530 I CONTROL [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49 2018-07-07T14:39:39.592+0530 I CONTROL [initandlisten] allocator: tcmalloc 2018-07-07T14:39:39.593+0530 I CONTROL [initandlisten] options: {} 2018-07-07T14:39:39.595+0530 I JOURNAL [journal writer] Journal writer thread started 2018-07-07T14:39:40.485+0530 I NETWORK [initandlisten] waiting for connections on port 27017 2018-07-07T14:40:39.140+0530 I NETWORK [initandlisten] connection accepted from 127.0.0.1:51340 #1 (1 connection now open) 2018-07-07T14:40:41.663+0530 I NETWORK [conn1] end connection 127.0.0.1:51340 (0 connections now open) 2018-07-07T14:45:12.421+0530 I NETWORK [initandlisten] connection accepted from 127.0.0.1:51578 #2 (1 connection now open) 2018-07-07T14:45:12.870+0530 I NETWORK [conn2] end connection 127.0.0.1:51578 (0 connections now open) 2018-07-07T14:46:21.734+0530 I NETWORK [initandlisten] connection accepted from 127.0.0.1:51591 #3 (1 connection now open) 2018-07-07T14:46:22.041+0530 I NETWORK [conn3] end connection 127.0.0.1:51591 (0 connections now open) 2018-07-07T14:57:47.523+0530 I NETWORK [initandlisten] connection accepted from 127.0.0.1:52534 #4 (1 connection now open) 2018-07-07T14:57:47.910+0530 I NETWORK [conn4] end connection 127.0.0.1:52534 (0 connections now open)

推荐答案

检查您的application.properties

check your application.properties

改变

spring.datasource.driverClassName=com.mysql.jdbc.Driver

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

为我工作.完整配置:

spring.datasource.url=jdbc:mysql://localhost:3306/db spring.datasource.username= spring.datasource.password= 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

更多推荐

无法配置数据源:未指定'url'属性,并且无法配置任何嵌入式数据源

本文发布于:2023-07-14 13:43:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104805.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据源   嵌入式   属性   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!