springboot2.0集成jdbc的數據源問題(已解決)

最近在學習springboot2.0,集成jdbc的時候老是給我報這個一個錯誤

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-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).

大概意思就是:找不到spring.datasource.url這個屬性的意思。在網上找了一萬種方法,都不是,他們都是不要數據源的,可我這要配置數據源啊,而且格式、配置文件、存放位置什麼的都對。

其實也是我的原因,我是看視頻學的springboot2.0 ,視頻裏面老師用的eclipse,而我用的idea,可能是我創建工程的原因,導致我的跟視頻裏的 pom.xml內容有點不一樣,之前沒仔細看,後來一行一行的對才發現的問題,如下圖
視頻eclipse裏的:
在這裏插入圖片描述
我的(idea):
在這裏插入圖片描述
之後我抱着試一試的態度,去掉了下面這行代碼

<packaging>pom</packaging>

結果 神奇的事情發生了,ok了,困擾我一下午的事情解決了,蒼天啊,淚崩。
至於什麼原因,我不是很明白,望各位大佬給我解一下惑。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章