使用jdk8学习JHipster教程

2024-04-10 1472阅读

使用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: prod
            

            D:\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
            
VPS购买请点击我

免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

目录[+]