Jhipster 建立簡單Demo
阿新 • • 發佈:2018-12-14
建立一個簡單的Jhipster Demo , 根據以下步驟可完成簡單建立:
1. 建立註冊中心:
git clone https://github.com/jhipster/jhipster-registry.git #根據官方提供的地址克隆檔案到本地
資料夾
# 檔案成功克隆到本地資料夾後, 進入該資料夾並按順序執行以下命令:
yarn install #安裝後端依賴
yarn start #編譯完成後執行Angular專案
mvnw # 執行後臺
在clone 註冊中心的原始碼程式碼時,可能速度很慢,慢慢等待吧! 當你執行 mvnw 命令並且後臺成功啟動後,可在http://localhost:8761/ 即可看到執行情況,具體效果圖如下:
2. 建立 uaa:
JHipster UAA是一種使用者會計和授權服務,用於使用OAuth2授權協議保護JHipster微服務。
mkdir uaa #建立一個新的目錄, 這裡uaa是目錄名稱,可進行自定義 cd uaa #進入剛建立的新目錄 jhipster #執行jhipster 命令 # 後面會出現這些問題,可根據自己的需求進行選擇 ? Which *type* of application would you like to create? JHipster UAA server (for microservice OAuth2 authentication) #微服務OAuth2的身份認證服務 ? What is the base name of your application? uaa #名稱 ?As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts. 9999 #埠 ?What is your default Java package name? com.mycompany.myapp #包名 ? Which service discovery server do you want to use? JHipster Registry (uses Eureka, provides Spring Cloud Config support and monitoring dashboards) #這裡選擇JHipster Registry ? Which *type* of database would you like to use? SQL (H2, MySQL, MariaDB, PostgreSQL, Oracle, MSSQL) #根據自己的需求選擇資料庫, 這裡我選擇sql ? Which *production* database would you like to use? MySQL ? Which *development* database would you like to use? MySQL ?Do you want to use the Spring cache abstraction? Yes, with the Hazelcast implementation (distributed cache, for multiple nodes) #選擇 用HAZELCAST實現 ? Do you want to use Hibernate 2nd level cache? yes #是否選擇二級快取 這裡yes ? Would you like to use Maven or Gradle for building the backend? Maven #專案選擇maven構建後端 也可以選擇gradle ? Please choose the native language of the application Chinese (Simplified) #應用程式本地語言 這裡我選擇簡體中文 ? Please choose additional languages to install ? Besides JUnit and Jest, which testing frameworks would you like to use? Gatling ? Would you like to install other generators from the JHipster Marketplace? (y/N) n # 應用程式生成成功後, 執行一下命令來啟動程式: yarn install #安裝依賴 mvnw #啟動後端
程式啟動成功後, 在註冊中心:http://localhost:8761/ 即可看到執行情況,具體效果圖如下:
3. 建立閘道器:
大體步驟和建立uaa一致,回答一系列問題後執行相同的命令來啟動後端,這裡直接只展示效果圖,不再贅述:
4. 建立微服務應用:
由於步驟與建立uaa和建立閘道器的步驟雷同, 所以這裡就只展示後端啟動成功後的效果圖:
在建立微服務時,需要在application-dev.yml 和 application-prod.yml 檔案中進行相應的配置 , 不然在啟動後端時會報錯。
到這裡就操作成功了。
5, 測試:
可以在service3中建立實體empinfo檢視在閘道器中
新人上路,請多指教!!!!!