JHipster – Introdução

Conceito

JHipster é um poderoso framework que ajuda a criar aplicações Java, Spring Boot e Angular.

Instalação

Pré-requisitos

  • Java 8
  • Node.js
  • Yarn

Instalando JHipster

Para instalação, execute os itens abaixo.

  • npm i -g bower
  • npm i -g yeoman-doctor
  • npm cache clean -f
  • npm i -g yo
  • npm install -g generator-jhipster

Criando projeto

Para criar um projeto.

  • Crie um diretório onde deseja que seja criado o projeto, por exemplo /opt/jhipster-teste/.
  • Execute o comando
    • yo jhipster
  • Ele poderá fazer algumas perguntas sobre ajuda anônima

Tipo de Aplicação

? Which *type* of application would you like to create? (Use arrow keys)
> Monolithic application (recommended for simple projects)
Microservice application
Microservice gateway
JHipster UAA server (for microservice OAuth2 authentication)

Nome da Aplicação

? What is the base name of your application? (jhipster)

Nome do Pacote

? What is your default Java package name? (com.mycompany.myapp)

Configuração de Monitor

? Do you want to use the JHipster Registry to configure, monitor and scale your application? (Use arrow keys)
> No
Yes

Tipo de Banco de Dados

? Which *type* of database would you like to use? (Use arrow keys)
> SQL (H2, MySQL, MariaDB, PostgreSQL, Oracle, MSSQL)
MongoDB
Cassandra
[BETA] Couchbase

Tipo de BD – Produção

? Which *production* database would you like to use? (Use arrow keys)
> MySQL
MariaDB
PostgreSQL
Oracle (Please follow our documentation to use the Oracle proprietary driver)
Microsoft SQL Server

Tipo de BD – Development

? Which *development* database would you like to use? (Use arrow keys)
> H2 with disk-based persistence
H2 with in-memory persistence
MySQL

Tipo de Cache

? Do you want to use the Spring cache abstraction? (Use arrow keys)
> Yes, with the Ehcache implementation (local cache, for a single node)
Yes, with the Hazelcast implementation (distributed cache, for multiple nodes)
[BETA] Yes, with the Infinispan (hybrid cache, for multiple nodes)
No (when using an SQL database, this will also disable the Hibernate L2 cache)

Hibernate 2nd level

? Do you want to use Hibernate 2nd level cache? (Y/n)

Ferramenta de build

? Would you like to use Maven or Gradle for building the backend? (Use arrow keys)
> Maven
Gradle

Outras tecnologias

? Which other technologies would you like to use? (Press <space> to select, <a> to toggle all, <i> to inverse selection
)
>( ) Social login (Google, Facebook, Twitter)
( ) Search engine using Elasticsearch
( ) WebSockets using Spring Websocket
( ) API first development using swagger-codegen
( ) Asynchronous messages using Apache Kafka

Client Framework (Angular)

? Which *Framework* would you like to use for the client? (Use arrow keys)
> Angular 5
AngularJS 1.x

Biblioteca SASS

? Would you like to enable *SASS* support using the LibSass stylesheet preprocessor? (y/N)

Internacionalização

? Would you like to enable internationalization support? (Y/n)

Idioma nativo

? Please choose the native language of the application (Use arrow keys)
> English
Estonian
Farsi
French
Galician
German
Greek
(Move up and down to reveal more choices)

Idiomas adicionais

? Please choose additional languages to install (Press <space> to select, <a> to toggle all, <i> to inverse selection)
>( ) Arabic (Libya)
( ) Armenian
( ) Catalan
( ) Chinese (Simplified)
( ) Chinese (Traditional)
( ) Czech
( ) Danish
(Move up and down to reveal more choices)

Frameworks de testes

? Besides JUnit and Karma, which testing frameworks would you like to use? (Press <space> to select, <a> to toggle all,
<i> to inverse selection)
>( ) Gatling
( ) Cucumber
( ) Protractor

Geradores adicionais

? Would you like to install other generators from the JHipster Marketplace? (y/N)

Geradores adicionais – escolha

? Which other modules would you like to use? (Press <space> to select, <a> to toggle all, <i> to inverse selection)
>( ) (ignite-jhipster-1.5.1) A React Native boilerplate for JHipster apps.
( ) (generator-jhipster-module-2.3.1) JHipster module, used to create a JHipster module
( ) (generator-jhipster-docker-2.4.0) Additional Docker support: Docker Hub, Local SMTP Server, NGinx
( ) (generator-jhipster-primeng-2.0.18) Generate PrimeNG Components
( ) (generator-jhipster-circleci-2-1.1.2) Generating CircleCI configuration file version 2 for a JHipster project
( ) (generator-jhipster-ci-1.0.0) JHipster module, Continuous Integration support in your JHipster application
( ) (generator-jhipster-bootstrap-material-design-3.5.1) Add Material design to your JHipster application
(Move up and down to reveal more choices)

Processo de instalação

yarn install v1.3.2
info No lockfile found.
[1/5] Validating package.json…
[2/5] Resolving packages…

Server application generated successfully.

Run your Spring Boot application:
./mvnw (mvnw if using Windows Command Prompt)

Client application generated successfully.

Start your Webpack development server with:
yarn start

Application successfully committed to Git.

Importando arquivo JDL

É possível criar um arquivo de modelagem do JHipster (arquivo .jdl) através do JDL-Studio:

https://start.jhipster.tech/jdl-studio/

Após gerar e baixar o arquivo (geralmente será jhipster-jdl.jh), no diretório do projeto.

Executar o comando para importar as entidades (veja que o arquivo foi renomeado):

$ jhipster import-jdl ./jhipster-jdl

Rodando a aplicação

Entre no diretório da aplicação e digite:

$ mvnw

Abrir um navegador e digitar:

http://localhost:8080 (usr e pwd: admin)

Leave a Reply