使用jdk8学习JHipster教程
使用jdk8学习JHipster教程
文章目录
- 使用jdk8学习JHipster教程
- 简介
- 1.安装JHipster
- 1.1 准备java8
- 1.2 准备node.js
- 1.3 安装JHipster
- 2.使用JHipster创建一个应用程序
- 2.1 找一个空文件夹
- 2.2 执行jhipster
- 2.3 后续结果如下
- 3.使用JHipster
- 3.1 打开项目
- 3.2 设置项目
- 3.2 启动
简介
JHipster是一个开发平台,可以快速生成、开发和部署现代Web应用程序和微服务架构,支持许多前端技术,包括Angular,React和Vue。
相信各位既然都已经看到了JHipster,应该也是对它有所了解了,在我看来这是一个很强大的全栈式脚手架。
1.安装JHipster
1.1 准备java8
我们首先需要jdk环境,关于java8的安装,可以查看我之前的文章——《Windows如何安装JDK8》。
1.2 准备node.js
我推荐使用nvm安装node.js,且官网要求,node.js版本必须是LTS版本,关于如何使用nvm安装node.js,可以查看我的这篇文章——《Windows安装nvm教程》。
成功安装nvm后请执行下面的指令,安装node.js的LTS版本,关于node.js的LTS版本具体有哪些,可以node.js的官方网站https://nodejs.org/en/download进行查阅。我们执行下面的命令安装v10.20.1。
nvm install 10.20.1
nvm use 10.20.1
node -v
npm -v
可以看到已经成功安装node 10.20.1。
1.3 安装JHipster
npm install -g generator-jhipster@6.10.5
JHipster版本6.10.5是最后一个支持Java8的版本了。
2.使用JHipster创建一个应用程序
官网教程可以参考《JHipster创建一个应用程序》。
2.1 找一个空文件夹
例如
mkdir D:\11\Documents\个人测试\app
cd D:\11\Documents\个人测试\app
2.2 执行jhipster
jhipster
2.3 后续结果如下
PS D:\11\Documents\个人测试\app> jhipster INFO! Using JHipster version installed globally INFO! Executing jhipster:app Welcome to JHipster v6.10.5 Application files will be generated in folder: D:\11\Documents\个人测试\app JHipster update available: 8.2.1 (current: 6.10.5) Run npm install -g generator-jhipster to update ? Which *type* of application would you like to create? Monolithic application (recommended for simple projects) ? [Beta] Do you want to make it reactive with Spring WebFlux? No ? What is the base name of your application? learnjhipster ? What is your default Java package name? com.cheung ? Do you want to use the JHipster Registry to configure, monitor and scale your application? No ? Which *type* of authentication would you like to use? JWT authentication (stateless, with a token) ? Which *type* of database would you like to use? SQL (H2, MySQL, MariaDB, PostgreSQL, Oracle, MSSQL) ? Which *production* database would you like to use? PostgreSQL ? Which *development* database would you like to use? PostgreSQL ? Do you want to use the Spring cache abstraction? Yes, with the Redis implementation ? Do you want to use Hibernate 2nd level cache? Yes ? Would you like to use Maven or Gradle for building the backend? Maven ? Which other technologies would you like to use? ? Which *Framework* would you like to use for the client? React ? Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster ? Would you like to enable internationalization support? Yes ? Please choose the native language of the application Chinese (Simplified) ? Please choose additional languages to install English ? Besides JUnit and Jest, which testing frameworks would you like to use? ? Would you like to install other generators from the JHipster Marketplace? No Installing languages: zh-cn, en
3.使用JHipster
3.1 打开项目
使用idea打开D:\11\Documents\个人测试\app
3.2 设置项目
D:\11\Documents\个人测试\app\src\main\resources\config\application.yml
设置生效文件为application-prod.yml
spring: application: name: learnjhipster profiles: # The commented value for `active` can be replaced with valid Spring profiles to load. # Otherwise, it will be filled in by maven when building the JAR file # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS` active: prodD:\11\Documents\个人测试\app\src\main\resources\config\application-prod.yml
设置你自己的postgresql数据库源
datasource: type: com.zaxxer.hikari.HikariDataSource url: jdbc:postgresql://localhost:5432/learnjhipster username: learnjhipster password:设置你自己的redis数据库源
jhipster: http: cache: # Used by the CachingHttpHeadersFilter timeToLiveInDays: 1461 cache: # Cache configuration redis: # Redis configuration expiration: 3600 # By default objects stay 1 hour (in seconds) in the cache server: redis://redis@localhost:6379/0 cluster: false若redis有密码,可以将auth认证这样写,第二个redis就是我的认证密码,使用0号数据库。
server: redis://redis@localhost:6379/0
3.2 启动
进入D:\11\Documents\个人测试\app执行下列命令。
./mvnw
