Professional Documents
Culture Documents
ebook download (eBook PDF) Full Stack Development with JHipster: Build modern web applications and microservices with Spring and Angular all chapter
ebook download (eBook PDF) Full Stack Development with JHipster: Build modern web applications and microservices with Spring and Angular all chapter
ebook download (eBook PDF) Full Stack Development with JHipster: Build modern web applications and microservices with Spring and Angular all chapter
(eBook PDF) Django for APIs: Build web APIs with Python
and Django
http://ebooksecure.com/product/ebook-pdf-django-for-apis-build-
web-apis-with-python-and-django/
http://ebooksecure.com/product/ebook-pdf-web-development-and-
design-foundations-with-html-7th/
http://ebooksecure.com/product/ebook-pdf-web-development-and-
design-foundations-with-html5-8th-edition/
http://ebooksecure.com/product/ebook-pdf-web-development-and-
design-foundations-with-html5-9th-edition-by-terry-felke-morris/
(eBook PDF) Parametric Modeling with Autodesk Fusion
360 (Spring 2019 Edition)
http://ebooksecure.com/product/ebook-pdf-parametric-modeling-
with-autodesk-fusion-360-spring-2019-edition/
https://ebooksecure.com/download/handbook-of-modern-coating-
technologies-applications-and-development-ebook-pdf/
(eBook PDF) Responsive Web Design with HTML 5 & CSS 9th
Edition
http://ebooksecure.com/product/ebook-pdf-responsive-web-design-
with-html-5-css-9th-edition/
http://ebooksecure.com/product/original-pdf-physics-for-
scientists-and-engineers-with-modern-physics-10th-edition/
http://ebooksecure.com/product/ebook-pdf-full-range-leadership-
development-2nd-edition/
About the reviewers
Julien Dubois is the creator and lead developer of JHipster. He has more than 20 years of
experience as a software developer, mainly in Java and Web technologies. He has a strong
knowledge of the Spring Framework, having coauthored a best-selling book on the subject,
and has managed SpringSourcebs France subsidiary.
Today, Julien works as the Chief Innovation Officer at Ippon Technologies, an IT consulting
company that has delivered many JHipster-based applications to its clients worldwide.
I would like to thank my wife, Auralie, and our children, Gabrielle, Adrien, and Alice, for
their patience during the reviewing of this book and the development of JHipster.
Antonio Goncalves is a senior Java developer expert on distributed systems. Despite being
a consultant, he loves to build bonds with the community, so he created the Paris Java User
Group and Devoxx France. As a JCP expert member on various JSRs, Antonio uses this
expertise to write books on Java EE and to talk at international conferences. For his
expertise and all of his work for the Java community, Antonio has been elected Java
Champion. Follow him on Twitter at !BHPODBM.
Spring Boot 30
Spring Security 30
Spring MVC 31
Spring data 31
Security 31
JWT 31
Session 32
OAuth2 32
Build tools 32
Maven 32
Gradle 33
Hibernate 33
Liquibase 33
Caching 33
Ehcache 34
Hazelcast 34
Infinispan 34
Swagger 34
Thymeleaf 34
Dropwizard metrics 35
WebSocket 35
Kafka 35
Testing frameworks 36
JUnit 36
Gatling 36
Cucumber 36
Introduction to database options 36
SQL databases 37
H2 37
MySQL 37
MariaDB 37
PostgreSQL 37
MS SQL 38
Oracle 38
NoSQL databases 38
MongoDB 38
Cassandra 38
Elasticsearch 39
Installation and setup 39
Prerequisites 39
[ ii ]
Table of Contents
Tools required 40
Installation procedure 40
Java 8 40
Git 41
Node.js 41
Yarn 42
Docker 42
IDE configuration 43
System setup 43
Installation of JHipster 44
Summary 45
Chapter 3: Building Monolithic Web Applications with JHipster 46
Application generation 47
Step 1 – preparing the workspace 47
Step 2 – generating code using JHipster 47
Server-side options 49
Client-side options 53
Internationalization options 54
Testing 55
Modules 56
Code walkthrough 58
File structure 59
Server-side source code 62
Java source 63
Resources 70
client-side source code 70
Starting the application 73
Application modules 74
Home and Login modules 75
Account modules 77
Settings 78
Password 78
Registration 79
Admin module 80
User management 80
Metrics 81
Health 82
[ iii ]
Table of Contents
Configuration 82
Audits 83
Logs 83
API 84
Running generated tests 84
Server-side tests 85
Client-side tests 85
Summary 86
Chapter 4: Entity Modeling with JHipster Domain Language 87
Introduction to JDL 87
DSL grammar for JDL 88
Entity modeling with JDL 88
Relationship management 89
DTO, service, and pagination options 90
JDL Studio 92
Use case entity model with explanation 93
Entities 93
Relationships 96
Options for entities 97
Entity generation with JHipster 99
Generated code walkthrough 100
Server-side source code 102
Domain class for the entity 102
Repository interface for the entity 105
Service class for the entity 105
Resource class for the entity 106
Client side 107
TypeScript model class for the entity 107
Angular services for the entity 107
Angular components of the entity 108
Angular route for the entity 109
Angular module for the entity 110
Generated pages 111
Running generated tests 114
Summary 115
Chapter 5: Customization and Further Development 116
Live reload for development 117
[ iv ]
Table of Contents
[v]
Table of Contents
[ vi ]
Table of Contents
Summary 201
Chapter 9: Building Microservices with JHipster 202
Application architecture 203
Gateway application generation 204
Converting a monolithic application to a microservice gateway 205
Application generation 206
Generating a new Gateway 207
Gateway configuration 213
JWT authentication 217
How JWT works 217
Microservice application - Invoice Service with MySQL database 220
Application generation 220
Microservice configuration 225
Microservice application - notification service with NoSQL
database 229
Application generation 229
Microservice configuration 231
Summary 232
Chapter 10: Working with Microservices 233
Setting up JHipster Registry locally 233
Using a pre-packaged WAR file 235
Building from source 237
Docker mode 237
Running a generated application locally 239
Gateway application pages 239
JHipster Registry pages 242
System status 243
Below renew threshold 243
Instances registered 243
General info and health 243
Application listing page 244
Metrics page 245
Health page 247
Configuration page 248
Logs page 248
Swagger API endpoints 249
[ vii ]
Table of Contents
[ viii ]
Table of Contents
Index 344
[ ix ]
Preface
This book, Full Stack development with JHipster, aims to address the following challenges
faced by full-stack developers today:
JHipster provides a platform for developers to easily create web applications and
microservices from scratch, without having to spend a lot of time wiring everything
together and integrating technologies together. This frees up time immensely for developers
to actually focus on their solution rather than spending time learning and writing
boilerplate code. JHipster will help novice and experienced developers to be more
productive from day one. It's like pair programming with an entire community.
This book will take you on a journey from zero to hero in full stack development. You will
learn to create complex production-ready Spring Boot and Angular web applications from
scratch using JHipster and will go on to develop and deploy features and business logic on
cloud services. You will also learn about microservices and how to convert a monolithic
application into the microservice architecture as it evolves using JHipster. Additionally, you
will learn how to make use of the new React support being introduced in JHipster and
about various best practices and suggestions from the JHipster community and the core
development team.
Preface
Full stack web app developers who want to reduce the amount of boilerplate they
write and save time, especially for greenfield projects.
Backend developers who want to learn full stack development with Angular or
React
Full-stack developers who want to learn microservice development
Developers who want to jump-start their full stack web application or
microservice development
Developers who want to quickly prototype web applications or microservices
$IBQUFS, Getting Started with JHipster, introduces the JHipster platform. It will also give
the reader a brief overview of different server-side, client-side, and DB technology options
offered by JHipster. This chapter will also provide instructions to install and use JHipster
and various tools and options supported by it.
$IBQUFS, Building Monolithic Web Applications with JHipster, guides the user through the
creation of a production-ready Spring boot and Angular web applications from scratch
using JHipster and will take the reader through the generated code, screens, and concepts.
$IBQUFS, Entity Modeling with JHipster Domain Language, introduces the reader to JHipster
domain language (JDL) and will teach build business logic with entity modeling and entity
creation using JDL and JDL studio.
[2]
Preface
$IBQUFS, Customization and Further Development, guides the reader through further
development of the generated application. It will also teach how to the reader more about
using technologies such as Angular, Bootstrap, Spring Security, Spring MVC REST, and
Spring Data.
$IBQUFS, Testing and Continuous Integration, guides the reader through testing and setting
up a continuous integration pipeline using Jenkins.
$IBQUFS, Going into Production, shows the reader how to use Docker and how to build and
package the app for production. It will also introduce the reader to some of the production
cloud deployment options supported by JHipster.
$IBQUFS, Building Microservices with JHipster, guides the reader through converting a
JHipster monolith web application into a full-fledged microservice architecture with a
Gateway, Registry, monitoring console, and multiple microservices. It will also guide the
reader through the generated code and components such as JHipster registry, JHipster
console, API gateway, and JWT.
$IBQUFS, Working with Microservices, guides the reader through running the generated
applications locally and creating domain entities for the microservice architecture using
JHipster domain language.
$IBQUFS, Deploying with Docker Compose, introduces the reader to advanced local and
cloud deployment options for microservices. It will also guide the user through local
deployment and testing of the generated microservice stack using Docker Compose and
JHipster.
$IBQUFS, Deploying to the Cloud with Kubernetes, guides the user through the Google
cloud deployment of the generated microservice stack using Kubernetes and JHipster.
$IBQUFS, Using React for the Client-Side, takes the user through generating an application
with React on the client side instead of Angular using JHipster.
$IBQUFS, Best Practices with JHipster, summarizes what the reader has learned so far and
will suggest best practices and next steps to utilize the skills learned.
[3]
Preface
It will also be easier if you are familiar with using technologies such as Docker and
Kubernetes, as it will help you grasp some of the chapters easily.
You will also need JDK8, Git, Docker, and NodeJS installed; your favorite web browser; a
terminal application; and your favorite code editor/IDE.
Once the file is downloaded, please make sure that you unzip or extract the folder using the
latest version of:
[4]
Preface
The code bundle for the book is also hosted on GitHub at IUUQTHJUIVCDPN
1BDLU1VCMJTIJOH'VMM4UBDL%FWFMPQNFOUXJUI+)JQTUFS. In case there's an update to
the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available
at IUUQTHJUIVCDPN1BDLU1VCMJTIJOH. Check them out!
Conventions used
There are a number of text conventions used throughout this book.
$PEF*O5FYU: Indicates code words in text, database table names, folder names, filenames,
file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an
example: "At the backend, modify the TBWF method of 1SPEVDU0SEFS4FSWJDFKBWB to
create an Invoice and Shipment for the 1SPEVDU0SEFS and save them all."
FOVN4J[F\
4.-9-99-
^
FOUJUZ1SPEVDU$BUFHPSZ\
OBNF4USJOHSFRVJSFE
EFTDSJQUJPO4USJOH
^
[5]
Preface
When we wish to draw your attention to a particular part of a code block, the relevant lines
or items are set in bold:
FOUJUZ1SPEVDU0SEFS\
QMBDFE%BUF*OTUBOUSFRVJSFE
TUBUVT0SEFS4UBUVTSFRVJSFE
invoiceId Long
DPEF4USJOHSFRVJSFE
^
Bold: Indicates a new term, an important word, or words that you see onscreen. For
example, words in menus or dialog boxes appear in the text like this. Here is an example:
"You can alternatively test this via your Gateway application. Log in to
our Gateway application and then navigate to Administration | Gateway."
Get in touch
Feedback from our readers is always welcome.
General feedback: Email GFFECBDL!QBDLUQVCDPN and mention the book title in the
subject of your message. If you have questions about any aspect of this book, please email
us at RVFTUJPOT!QBDLUQVCDPN.
[6]
Preface
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you have found a mistake in this book, we would be grateful if you would
report this to us. Please visit XXXQBDLUQVCDPNTVCNJUFSSBUB, selecting your book,
clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we
would be grateful if you would provide us with the location address or website name.
Please contact us at DPQZSJHIU!QBDLUQVCDPN with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in
and you are interested in either writing or contributing to a book, please visit
BVUIPSTQBDLUQVCDPN.
Reviews
Please leave a review. Once you have read and used this book, why not leave a review on
the site that you purchased it from? Potential readers can then see and use your unbiased
opinion to make purchase decisions, we at Packt can understand what you think about our
products, and our authors can see your feedback on their book. Thank you!
[7]
Introduction to Modern Web
1
Application Development
According to the Stack Overflow developer survey 2017 (IUUQTJOTJHIUT
TUBDLPWFSGMPXDPNTVSWFZEFWFMPQFSQSPGJMFTQFDJGJDEFWFMPQFSUZQFT), full-
stack web developer is the most popular developer title. The software industry defines a full-
stack developer as someone who can work on different areas of an application stack. The
term stack refers to different components and tools that make up an application.
In terms of web application development, the stack can be broadly classified into two
areascfrontend and backend stack or client-side and server-side stack. Frontend generally
refers to the part that is responsible for rendering the user interface, and backend refers to
the part that is responsible for the business logic, database interactions, user authentication,
server configuration, and so on. A full-stack Java web application developer is expected to
work on both frontend and backend technologies, ranging from writing HTML/JavaScript
for the user interface to writing Java class files for business logic and SQL queries for
database operations as required.
With an ever-evolving software architecture landscape, the scope of technologies that a full-
stack web developer is expected to work has increased tremendously. It is no longer enough
that we can write HTML and JavaScript to build a user interface, we are expected to know
client-side frameworks such as Angular, React, VueJS, and so on. It is also not enough that
we are proficient in enterprise Java and SQL, we are expected to know server-side
frameworks such as Spring, Hibernate, Play, and so on.
Another random document with
no related content on Scribd:
Aconteció una vez que se alzó un muchacho; y después de haber
estado cerca de un cuarto de hora en la susodicha forma de
interrogante, sin obtener respuesta, díjole don Bernabé:
—¡Corre, que te pillan!
Y el chico apretó á correr hacia la puerta.
—¿Adónde va, candonga?—le gritó el dómine.—¡Vuelva, vuelva, y
póngamelo en latín!
Volvió el muchacho, y, torpe y atarugado, comenzó á decir:
—Curre... quod... pillant...
—¡No estás tú mal pillo, calabaza!—Y deslomóle de un bastonazo.
—¡Á ver, el otro!
Y como el otro no estuviese más acertado que su antecesor,
continuó el de más allá, y luego el que le seguía, y después el otro,
y, por último, los mayoristas, que tampoco supieron vencer la
dificultad, con lo que don Bernabé fué entrando en calor, y la
bromita del «corre, que te pillan» acabó en tragedia.
Tal era el lado cómico de este personaje. Fiar en sus chistes,
equivalía á retozar con el tigre. Al fin, siempre había zarpada.
IV
Y ahora quisiera tener yo á mi lado á los más sutiles fisiólogos del
mundo, para que me explicaran el fenómeno de aquella singular
naturaleza; cómo podía ser á un mismo tiempo el más empedernido
y sanguinario de los maestros, y el mejor de los hombres. Porque es
de saberse que don Bernabé Sáinz, fuera de su cátedra, lo era de
pies á cabeza. Jamás he conocido persona más inofensiva, más
sencilla, más bondadosa. Un niño le engañaba en la calle, un
juguete le entretenía, el menor acontecimiento le asombraba. Su
integridad rayaba en manía.
Tenía pupilos, ordinariamente. Cuando se trataba de repasarles la
lección, era el tigre del Instituto; pero en la mesa, en el paseo, en la
intimidad del hogar, era un amigo, un padre cariñosísimo para ellos,
como lo era para todos sus discípulos en cuanto dejaban de serlo.
Á mi modo de ver, era un pobre hombre poseído de un demonio: el
demonio del fanatismo, el fanatismo de la enseñanza. Si castigaba á
un discípulo con un día de calabozo, dejaba de comer para ir á
tomarle la lección de la tarde en el calabozo mismo. Iba á clase
hasta con calentura á cumplir con su deber, y su deber era enseñar
latín, porque creía haber nacido para eso. Si una consulta sobre la
traducción pendiente le robaba el sueño, tanto mejor: ningún hecho
más digno, en su concepto, de consignarse en la hoja de servicios
de sus alumnos. Presentaba los buenos en un examen con el
orgullo y el amor de un general que ve desfilar, en ostentosa parada,
á sus valientes veteranos cargados de cruces; y hablaba de ellos en
todas partes, y los seguía con la atención á la Universidad, y aunque
allí claudicasen, jamás los apartaba ya de su memoria. Llena de
esos nombres la tuvo hasta la hora de su muerte. Muchas veces me
los citó conmovido y entusiasmado, y por el menos brillante de
aquellos «chicos» hubiera dado él, sin titubear, á ser preciso, la
diestra con que tantas veces le deslomó á varazos.
En una ocasión, después de haber oído la razón que le dió un
discípulo de haber faltado á la clase el día antes, le oí decir:
—Candonga, ¿y por eso no vino? ¿Sabe cómo vengo yo todos los
días y cómo vivo? Pues óigalo, calabaza. Hace veinte años que
estoy enseñando latín, y quince que la mujer no sale de la cama; me
consume cuanto gano, y no tengo más que lo puesto; los únicos
ahorros que había hecho se los presté á un compañero que no me
los ha de pagar en los días de su vida, y lo mejor de cada noche me
lo paso en claro velando á la enferma. ¿Les parece poco? ¡Ah,
candonga! ¡Si os cogieran los tiempos que á mí me cogieron para
aprender latín, ya os darían confites en estos lances, y os
guardarían los miramientos que yo os guardo! Enfermo, y con la
nieve á la rodilla, fuí yo una noche á casa de un compañero que
tenía Calepino; para sacar un significado de la traducción del día
siguiente... Y ¡pobre de mí, candonga, si llego á ir al aula sin
sacarle!... Y sepan, calabaza, que para entonces ya había servido
yo al rey seis años en una compañía de fusileros: dos de soldado
raso, uno de furriel y tres de sargento.
He aquí algo á que se agarrarían los fisiólogos llamados á explicar
las crueldades profesionales de un hombre tan manso y apacible.
Don Bernabé enseñaba como le habían enseñado á él: á estacazos.
La costumbre fué haciéndose naturaleza poco á poco. La escasez
de entendimiento, lo extremado del amor al oficio, los resabios del
cuartel y las tradiciones del sistema, hicieron lo demás. No era á sus
ojos mayor delito que echar malè en una lección, faltar con palabras
un soldado raso á un triste cabo segundo; y, sin embargo, la
Ordenanza militar castiga estas faltas con el presidio, si no con la
muerte, ¡y él se conformaba con apalear á los delincuentes de su
cátedra!
Hasta dónde llegaban su sencillez y su puntillo de hombre de cuenta
y razón, muéstralo el hecho siguiente, que no fué el único en su
género:
Llegóse una vez á cobrar la paga del mes á secretaría, y diéronsela
con la merma de cierta cantidad que le correspondía pagar por no
sé qué gastos hechos por todo el Claustro de profesores.
—Venga mi paga entera,—dijo don Bernabé negándose á recoger lo
que le entregaban.
—Pues ahí la tiene usted—le replicaron.—Tanto que usted debe, y
tanto que le entrego, hacen lo que le corresponde.
—¡Venga mi paga entera, candonga!—insistió.
Diéronle lo que le faltaba.
—¿Cuánto debo yo?—preguntó al tener todo el dinero en la mano.
—Tanto.
—Pues ahí va,—dijo entregándolo y guardándose el resto después
de contarlo.
—¿Cuánto le queda á usted ahora?
—Tanto.
—Lo mismo que yo entregaba á usted antes.
—Nunca lo negué, candonga; pero yo soy hombre de cuenta y
razón, y para tan cortos caudales no necesito mayordomos; y como
pago de lo mío, quiero pagar con mi mano, ¡calabaza!
El nuevo plan de estudios le transformó radicalmente. Continuó
siendo en la cátedra una fiera, pero con bozal y sin uñas. Perdió así
lo mejor de sus bríos, y se entibió su entusiasmo por la enseñanza.
No la comprendía sin palos y sin sangre. Andaba triste y
desperdigado; y como ya era viudo y sin hijos, se casó con la criada.
Le dieron una cencerrada espantosa: tres noches duró; y no duró
más, porque habiéndole insultado groseramente los actores, los
dispersó á tiros desde el balcón, en lo cual obró como un sabio y en
justicia.
Murió el año de 1865, víctima del cólera que diezmó la población de
Santander; y es de advertir que ni este espantoso azote pudo doblar
aquel rígido carácter antes de romperle, puesto que don Bernabé
fué á cátedra invadido ya por la enfermedad, salió á la hora
reglamentaria, y sólo se metió en el lecho para rendir cristianamente
el alma á Dios.
En resumen, lector: en mi sentir, las crueldades del dómine, aunque
lamentables, é hijas, más que del corazón, del tiempo, de las
costumbres y de las leyes que las toleraban y hasta las aplaudían,
no hacen al íntegro y virtuosísimo personaje indigno de la
estimación de las gentes hidalgas. Me complazco en declararlo así,
en honra del hombre que más me ha hecho padecer en menos
tiempo. Pero no me arrepiento de haber pintado á Filipo por los dos
lados; pues si el vivir bajo el imperio de su barbarie me acongojaba
entonces, hoy, que tengo hijos, me espanta el pensar que puede
quedar todavía algo de ella en los centros de enseñanza...
Obra es, pues, de caridad sacar esa barbarie al rollo, para lección
de incautos y castigo de verdugos.
1878.
LAS TRES INFANCIAS[7]