spring cloud(學習筆記)微服務啟動錯誤(1)


今天下午在啟動spring cloud微服務的時候,報了這個錯誤:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-07-03 20:17:10.295 ERROR 19024 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

Disconnected from the target VM, address: '127.0.0.1:55393', transport: 'socket'

Process finished with exit code 1

剛開始我以為是端口被占用。果斷cmd並輸入netstat -aon,找半天沒發現占用的端口,然后又網上看了一下,

轉自:https://blog.csdn.net/Loser100/article/details/78190703?locationNum=9&fps=1

SpringBoot啟動報錯:Cannot determine embedded database driver class for database type NONE

springboot啟動時會自動注入數據源和配置jpa

解決辦法一:

啟動類中加入注解:@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})

解決方法二:

在Application.properties文件內配置數據源即可。代碼如下:
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5

我仔細的檢查了一下,也加了注解,試了一下,我靠,沒用啊,人生吶,真是改不完的bedug,

只好用出終極大招,拷貝我自己的代碼,刪除項目,從新從svn更新項目,導入運行,哎呦我去。怎么還是這問題?難道是我項目配置問題?不對啊,我其他的項目都沒有問題啊。束手無策,只好求助小碗(一個認真工作的大佬);

 

通過反復調試,終於找到了。問題所在,pom.xml里面有一個錯誤的配置,

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

刪了就可以運行,微服務也可以注冊。配置文件請大家仔細檢查。配置文件不對,什么都是扯淡。

 

 

歡迎大家關注公眾號,不定時干貨,只做有價值的輸出

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM