springboot執行的第乙個檔案

2021-10-17 08:46:31 字數 964 閱讀 2750

以寫乙個controller檔案為例子,**如下 

@restcontroller

public class helloworldcontroller

}

@componentscan("com.example")
com.example是因為pom.xml配置

com.example
2 在不同的包中要匯入

com.example

content

$

3 感覺**沒有問題,把專案重構一下,build,還有位址要記得改

使用兩個外掛程式lombok和free mybatis plugin

lombok的作用是可以列印日誌@slf4j,@data可以自動獲得屬性的get, set方法就不用人工寫了,@allargsconstructor 可以生成乙個具有該所有屬性的構造方法。

學習序列化(要做的事情)

資料庫用的是postgresql, 連線用的是alibaba的資料庫連線池,mybatis用的是com.baomidou/mybatis-plus-boot-starter

主要是配置資訊

url: jdbc:postgresql://localhost:5432/postgres

username: postgres

password: 150920

1 寫一些返回前台固定的資訊,需要有乙個列舉類,在response資料夾下

2 mybatisplusconfiguration類,配置檔案

@configuration

public class mybatisplusconfiguration

}

有乙個生成模型的父類basemodel裡面是createby,...updatetime.

執行codegenerator,在控制台輸入表名,就可以了

現在我們就可以開始寫業務邏輯了

SpringBoot執行流程

通過上面這個簡要示意圖,可以看出,只要將事件通知的擴充套件點忽略,springboot的執行流程並不是想象中那麼複雜。public void started void environmentprepared configurableenvironment environment public int...

Spring Boot 啟動執行

public static void main string args return run new class args spring boot主程式main方法只做了兩件事 this null,primarysources resourceloader null this.resourceloa...

SpringBoot 第一次配置(一)

2.不用安裝直接解壓去配置即可 配置環境 3.測試安裝結果 需要注意的點 1 第一次配置pom載入的有點慢 3 加入依賴 2.寫個控制類 controller public class hello 3.直接去執行主程式 componentscan basepackages com.xiaonuo p...