这里只介绍我初次使用jhipster搭建项目的过程,其他不多做介绍。有需要请到jhipster官网或jhipster中文网
环境准备
1.安装node.js与npm(https://nodejs.org/zh-cn/)
最新版本的node.js会默认安装npm,使用node -v与npm -v 查看是否成功安装。
2.安装yeoman
npm install -g yo
3.安装jhipster
npm install -g generator-jhipster
创建jhipster项目
1.创建一个文件夹,通过cmd 进入该目录,然后输入命令: jhipster 回车会出现如下界面:

2.选择需要创建的应用类型:这里有单体应用,微服务,微服务网关,基于OAuth2的安全认证微服务四种应用可供我们选址,这里我选择创建的是单体应用。

3.项目名称,不输入默认以之前创建的文件夹名为项目名。

4.项目的包名。(注:使用Yeoman的时候此值会被存储,当下次使用的时候此值会成为默认值,可覆写此值)

5.JHipster Registry选择,只有在微服务架构时才会使用(我这里创建的单体引用,所以选择N)

6.选择认证类型。

7.选择数据库。



10.缓存模式选择。

11.是否开启Hibernate二级缓存。

12.选择构建项目的工具。

13.这里支持你为应用添加多种技术。(A键与I键都能进行全选与取消全选,空格进行单选与取消)

14.选择前端使用技术。

15.是否使用SASS样式。

16.国际化。(一般对于国际化要求不多的场景,可以不选择)



19.JUnit单元测试模式选择。

20.是否需要去JHipster商城安装第三方插件模块。

21.出现如下界面,说明我们项目成功创建了

项目目录结构如下

使用JHipster域模型自动生成Dao、Model等相关文件
1.可以到https://start.jhipster.tech/jdl-studio/网址获取jhipster-jdl.jh文件,根据自己的需要创建域模型,点击右上角的下载按钮,然后将该文件放入项目的根目录。(了解jhipster域语言:http://www.jhipster.net/html/1/217/218/index.html)

2.(cmd)进入项目根目录,运行 jhipster import-jdl jhipster-jdl.jh 引入该文件并生成相关文件,如下图:


3.创建一个数据库并修改项目application-dev.yml文件数据库地址

4.进入项目根目录,运行mvnw命令,然后到数据库查看,会看到自动根据域模型生成的数据库表


5.使用idea或eclipse工具打开项目然后run方式运行,通过http://8080访问,默认登录名与密码为(admin)

网友评论