Jhipster 创建简单Demo

创建一个简单的Jhipster Demo , 根据以下步骤可完成简单创建:

1. 创建注册中心:

       Jhipster官方提供注册中心的源码代码,可以直接运行,  官方注册中心地址:https://github.com/jhipster/jhipster-registry.git

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查看在网关中是否能够调用服务。

新人上路,请多指教!!!!!

参考文章:https://my.oschina.net/niepanLs/blog/792493

                 https://juejin.im/post/5b1c7f605188257d3a6973a0

 

 

 

 

  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章