Spring Cloud Jhipster (程式碼生成器)
1.介紹
Jhipster是基於nodejs+yeoman的java程式碼生成器。它集成了spring cloud的一些技術,採用問答式方法,構建一整套技術解決方案。
使用到的技術如下:
客戶端:
伺服器端:
2.使用Jhipster生成專案
2.1在安裝了node.js,yeoman之後,cd到生成目錄的地址,用命令yo jhipster.
2.2 互動式問題
問題解釋:
(1/16).which *type* of application would you
選擇建立的應用型別,這裡我選擇第一個,第一個可以生成web應用
> Monolithic application (recommended for simple projects) //綜合應用
Microservice application //微服務應用
Microservice gateway //微服務閘道器
(2/16). What is the base name of your application? //服務名,這裡用jhipsterdemo(注意,不允許有空格)
(3/16) Would you like to install other generators from the JHipster Marketplace
(4/16).What is your default Java package name //預設包名,這裡用的是com.wzc.jhipster
(5/16).Which *type* of authentication would you like to use? //選擇認證方式,這裡我選擇第一種,無狀態基於token驗證
JWT authentication (stateless, with a token) //J(son)W(eb)T(oken)(無狀態)
Authentication with JHipster UAA server (the server must be generated separately) //jhipsterUAA 認證服務,需要單獨建立
(6/16).Do you want to use the JHipster Registry to configure, monitor and scale your application?//jhipster registry是一個基於spring cloud的配置中心。所有的微服務APP都需要註冊到這裡,集成了eureka
(7/16). Which *type* of database would you like to use? // 使用那種資料庫
SQL (H2, MySQL, MariaDB, PostgreSQL, Oracle) //關係型資料庫
MongoDB //NoSQL
Cassandra //NoSQL
(8/16).Which *production* database would you like to use ? //生產資料庫
MySQL
MariaDB
PostgreSQL
Oracle - Warning! The Oracle JDBC driver (ojdbc) is not bundled because it is not Open Source. Please follow our documentation to instal l it manually.
(9/16) Which *development* database would you like to use? //開發資料庫
H2 with disk-based persistence //資料儲存在磁碟的H2
H2 with in-memory persistence //記憶體H2(服務關閉資料丟失)
MySQL
(10/16) Do you want to use Hibernate 2nd level cache? //二級快取
Yes, with ehcache (local cache, for a single node) //本地快取方案 ehcache
Yes, with HazelCast (distributed cache, for multiple nodes) //叢集快取方案,多節點快取,適合多微服務的分散式環境
(11/16) Would you like to use Maven or Gradle for building the backend? //選擇後臺構建系統
> Maven //更成熟,穩定,使用者群體更大
Gradle //更靈活,易於擴充套件,支援maven一鍵轉Gradle
(12/16) Which other technologies would you like to use? Social login (Google, Facebook, Twitter), WebSockets using Spring Websocket //可選技術
( )Social login (Google, Facebook, Twitter) //第三方社交登入,基於OAuth2.0
( )Search engine using ElasticSearch //整合搜尋開源搜尋引擎 ElasticSearch
( ) Clustered HTTP sessions using Hazelcast //使用Hazelcast管理http session叢集
( ) WebSockets using Spring Websocket //使用Spring Websocket
( ) [BETA] Asynchronous messages using Apache Kafka //Apache Kafka 是一種高吞吐量的分散式釋出訂閱訊息系統
(13/16) Which *Framework* would you like to use for the client?
(14/16) Would you like to use the LibSass stylesheet preprocessor for your CSS? No
(15/16) Would you like to enable internationalization support? //是否使用國際化
Please choose the native language of the application? English //選擇本地化語言
Please choose additional languages to install Chinese (Simplified) //選擇其餘支援語言
(16/16) Besides JUnit and Karma, which testing frameworks would you like to use? //預設情況下 JHipster 提供 java 單元/整合測試(使用Spring JUnit支援)和 JavaScript 單元測試(使用Karma.js)
(*) Gatling //使用 Gatling 進行效能測試。
( ) Cucumber //使用 Cucumber 模擬使用者行為
生成目錄如下:
3.啟動專案
進入com.wzc.jhipster 右鍵JhipsterwebApp.java,run as java application。即可啟動,介面如下: