Jhipster框架简介及快速搭建项目

Jhipster是为您生成一个完整的现代Web应用程序或微服务架构:
它使用Spring Boot在服务器端实现高性能和强大的Java堆栈,这是一款时尚,现代,移动优先的前端,配有Angular,React和Bootstrap,一个强大的微服务架构。

1.环境搭建

  • 从Oracle网站安装Java 8 。
  • 从Node.js网站安装Node.js (请使用LTS 64位版本,不支持非LTS版本)
  • npm install -g npm
  • 要安装Yeoman,请键入: npm install -g yo
  • 要安装JHipster,请键入: npm install -g generator-jhipster
    2.开始创建项目
    使用命令创建一个新文件夹
mkdir demo

在这里插入图片描述
进入到该文件夹当中

cd demo

在这里插入图片描述
执行

jhipster

回答你看到的问题,这些问题用于定制你的应用,稍后详细解释每个问题。
在这里插入图片描述
回答各种问题之后,创建成功如下(问题在最下面展示)
在这里插入图片描述
在这里插入图片描述
通过idea打开项目,maven自动下载依赖(最好设置一下maven下载地址,下载jar包会快一些)
在这里插入图片描述
修改配置文件:如数据库的名、用户密码等
执行spring boot的启动类
项目运行成功
在这里插入图片描述
搭建项目时候会出现的问题:(并不是很完整,推荐去看官方文档)
Q1. Which type of application would you like to create?
Monolithic application: 单体应用
Microservice application: 微服务架构的service
Microservice gateway: 微服务网关,为微服务请求进行路由和安全
JHipster UAA server: 基于OAuth2的安全认证微服务,后文详细解释

Q2. What is the base name of your application?
你期望的应用的名称

Q3. What is your default Java package name?
应用使用的默认包名,使用Yeoman的时候此值会被存储,当下次使用的时候此值会成为默认值,可覆写此值

Q4. Do you want to use the JHipster Registry to configure, monitor and scale your application?
JHipster Registry是一个开源的工具,用于管理你正在运行的应用(微服务注册中心和统一配置中心),只有在微服务架构时才会使用

Q5. Which type of authentication would you like to use?
所有可能的答案:
JWT authentication: 使用JSON Web Token
HTTP Session Authentication:经典的基于session认证的机制
OAuth 2.0 / OIDC Authentication: 使用OpenID连接服务,类似于Keycloak或者Okta
Authentication with JHipster UAA server: 此种方式必须提前生成JHipster UAA Server (Q1的选项),它是基于OAuth2的验证服务

Q6. Which type of database would you like to use?
你可以选择的选项:
No database,仅使用微服务架构时可用
An SQL database: 使用关系型数据库,将会采用Spring data jpa
MongoDB
Cassandra
Couchbase

Q7. Which production database would you like to use?
选择你线上环境使用的数据库,此选项决定src/main/resources/config/application-prod.yml的配置

Q8. Which development database would you like to use?
此选项决定你src/main/resources/config/application-dev.ymlprofile的数据库配置项,你可以选择:
H2,running in-memory,数据存储在内存中,服务停掉数据消失
H2,with its data stored on disk,数据存储在硬盘,当前只是BETA测试且不能在Windows机器上工作
可以和Q7的选项一致

Q9. Do you want to use the Spring cache abstraction?
由于Spring对于Cache的允许用户使用不同的cache实现,你可以使用chcache(本地缓存),Hazelcast(分布式缓存)或者Infinispan(另一种分布式缓存),此选项可以提升你的应用的性能

Q10. Do you want to use Hibernate 2nd level cache?
此选项仅当你选择SQL数据库并且在Q9选择了一个缓存实现。Hibernate使用二级缓存可以更好的提升它的性能

Q11. Would you like to use Maven or Gradle?
构建此项目时将要使用的工具,Maven或者Gradle

Q12. Which other technologies would you like to use?
多选,你可以为你的应用添加多种技术,如:
Social login,社交登录功能
API first development using swagger-codegen:通过成swagger-codegen而使你的应用采用API优先的开发模式
Search engine using ElasticSearch: 对于ES的支持(Spring Data Elasticsearch)
Clustered HTTP sessions using Hazelcast,默认情况下,JHipster只是用Http Session来存储Spring Security的身份验证和授权信息。如果你在集群中运行,使用HTTP Session将会导致一些数据一致的问题,如果你想在集群中复制session,请选择此项

Q13. WebSockets using Spring Websocket
启用Websockets支持,将使用Spring WebSocket,JHipster提供了简单的例子展示如和高效的使用

Q14. Asynchronous messages using Apache Kafka
是否使用Kafka来发布和订阅消息

Q15. Which Framework would you like to use for the client?
选择使用那种客户端技术:

Q16. Would you like to use the LibSass stylesheet preprocessor for your CSS?
Node-sass对于设计CSS是一个优秀的解决方案,便于高效使用,你需要运行一个Gulp服务,jhipster会自动配置

Q17. Would you like to enable internationalization support?
JHipster对于国际支持非常友好,你可以在客户端和服务端使用。但一般对于国际化要求不多的场景,可以不选择。

Q18. Which testing frameworks would you like to use?
默认Jhipster提供了Java单元/集成测试(spring`s Junit)和JavaScript单元测试(Karma.js),你也可以选择:
Performance tests using Gatling,性能测试 Gatling
Behaviour tests using Cucumber,行为测试 Cucumber
Angular integration tests with Protractor, angular集成测试Protractor

Q19. Would you like to install other generators from the JHipster Marketplace?
是否需要去JHipster商城安装第三方插件模块

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

微微笑再加油

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值