原學習文章路徑 juejin.im/post/5c7a43…java
@Component //可被注入spring容器
複製代碼
idea建立springboot項目時發現鏈接不上spring.io 。後來才知道在Preferences下搜HTTP Proxy選Auto-detect proxy settings應用便可。mysql
啓動項目報警 (雖然對這簡單的demo看似沒影響,但在網上仍是找到能夠解決的辦法。)spring
WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
複製代碼
解決:數據庫鏈接增長參數 ?useSSL=false
複製代碼
jdbc:mysql://127.0.0.1:3306/dbgirl?useSSL=false
複製代碼
配置好數據庫鏈接與實體類後啓動項目後發現多出hibernate_sequence 表 解決:sql
@GeneratedValue增長數據庫
@GeneratedValue(strategy = GenerationType.IDENTITY)
複製代碼
緣由是默認不加後面括號 是會默認選擇strategy = GenerationType.AUTO,由數據庫自動選擇主鍵生成策略。springboot
idea直接啓動bash
控制檯進入項目根目錄路徑 輸入app
mvn spring-boot:run
複製代碼
先打包,可在idea裏install或在控制檯輸入ide
mvn install
複製代碼
而後可見target目錄多了一個jar包,而後在控制檯進臺target目錄輸入spring-boot
java -jar 項目名-版本號.jar
複製代碼
切換版本
帶參啓動服務
java -jar 項目名-版本號.jar --spring.profiles.active=XXX
複製代碼