重構:
調整主(父)工程型別(packge)
建立子模組工程(module)
模組層:model
持久層:persistence
表示層:view
複製程式碼
子模組依賴管理(dependencyManagement)
修改POM:

之前package裡面是jar,修改成pom。
在專案中新建一個module:

新建一個maven的module,起名為Web。
開啟裡面的pom,可以看到裡面已經有了依賴。
父級別module裡面有了變化:

把父級的src裡面的程式碼都移植到web module中:

刪除原來的module,試著跑一下。

成功。
同樣方法,建立persistence,把web中的repository中的class放入persistence中的repository中:

同樣的方法建立model
但是會發現class中會報錯,那是因為沒有建立歷來關係。
接著在pom中配置依賴關係:
web的:

persistence的

這樣子各個model就會建立如下的依賴關係:
web controller依賴於 persistence repository 依賴於 model domain
(其中出現了一個錯誤,配置完以後還是無效,在pom中能跳轉但是就是沒有產生依賴。搞了很長時間,才發現在類中,匯入maven的包失效了,我覺得是library的問題,在project structure中的library中發現有報錯,把其中兩個module的library中的classes刪除,錯誤消失,就能獲取到import的包,具體原理還不清楚。)
再跑一遍整個專案,成功。

和狗子一起成為更好的人。