1. 程式人生 > >搭建SpringBoot工程以及初期可能遇到的錯誤

搭建SpringBoot工程以及初期可能遇到的錯誤

1. 快速搭建

 

2填寫專案資訊

        

3,點選生成專案

4,簡單演示

新建maven專案

 

點選下一步

 

         點選下一步

         

         點選完成

         複製下載下來的專案到新建專案中


1, 關閉特定的自動配置

使用@SpringBootApplicationexclude(除去,不包括)引數,例如,關閉自動配置資料來源。

不然啟動的時候可能會出現錯誤

錯誤資訊如下:

***************************
APPLICATION FAILED TO START
***************************
Description:
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).

可以寫如下圖的測試方法,右鍵Run As-->java application執行,在瀏覽器裡直接訪問http://localhost:8080/就能看到頁面顯示hoan的字樣子。