(Ebook PDF) Full Stack Development With Jhipster: Build Modern Web Applications and Microservices With Spring and Angular
(Ebook PDF) Full Stack Development With Jhipster: Build Modern Web Applications and Microservices With Spring and Angular
com
https://ebooksecure.com/product/ebook-pdf-full-
stack-development-with-jhipster-build-modern-web-
applications-and-microservices-with-spring-and-
angular/
(eBook PDF) Django for APIs: Build web APIs with Python
and Django
https://ebooksecure.com/product/ebook-pdf-django-for-apis-build-web-
apis-with-python-and-django/
ebooksecure.com
https://ebooksecure.com/product/ebook-pdf-web-development-and-design-
foundations-with-html-7th/
ebooksecure.com
https://ebooksecure.com/product/ebook-pdf-web-development-and-design-
foundations-with-html5-8th-edition/
ebooksecure.com
https://ebooksecure.com/product/ebook-pdf-psychoanalytic-
psychotherapy-a-handbook/
ebooksecure.com
(eBook PDF) Teaching Humanities and Social Sciences
History Geography, Economics Citizenship in the Australian
6th
https://ebooksecure.com/product/ebook-pdf-teaching-humanities-and-
social-sciences-history-geography-economics-citizenship-in-the-
australian-6th/
ebooksecure.com
https://ebooksecure.com/product/original-pdf-canadian-democracy-a-
concise-introduction/
ebooksecure.com
https://ebooksecure.com/download/concrete-composite-columns-behavior-
and-design-ebook-pdf/
ebooksecure.com
https://ebooksecure.com/product/mcminn-and-abrahams-clinical-atlas-of-
human-anatomy-7th-edition-ebook-pdf/
ebooksecure.com
https://ebooksecure.com/product/ebook-pdf-principles-of-conservation-
biology-3nd-edition/
ebooksecure.com
(eBook PDF) The Law and Special Education 5th Edition by
Mitchell L. Yell
https://ebooksecure.com/product/ebook-pdf-the-law-and-special-
education-5th-edition-by-mitchell-l-yell/
ebooksecure.com
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 ]
Visit https://testbankfan.com
now to explore a rich
collection of testbank or
solution manual and enjoy
exciting offers!
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]
Exploring the Variety of Random
Documents with Different Content
"And I direct that, after my death, the alimentary
organs be removed entire with their contents from my
body, commencing with the œsophagus and ending
with the anal canal, and that they be properly secured
at both ends with a suitable ligature, and be enclosed
in a proper preservative medium in a glass vessel and
given to my great-nephew Thomas Macpherson of the
Stone Cottage, Gatehouse-of-the-Fleet, in
Kirkcudbrightshire, now studying medicine in
Aberdeen. And I bequeath him these my alimentary
organs with their contents for his study and edification,
they having served me for ninety-five years without
failure or defect, because I wish him to understand that
no riches in the world are comparable to the riches of a
good digestion. And I desire of him that he will, in the
exercise of his medical profession, use his best
endeavours to preserve to his patients the blessing of
good digestion unimpaired, not needlessly filling their
stomachs with drugs out of concern for his own pocket,
but exhorting them to a sober and temperate life
agreeably to the design of Almighty Providence."
After this remarkable passage, the document went on to make
Robert Ferguson residuary legatee without particular specification of
any property, and to appoint a firm of lawyers in Glasgow executors
of the will.
Wimsey considered the bequest for some time. From the
phraseology he concluded that old Mr. Ferguson had drawn up his
own will without legal aid, and he was glad of it, for its wording thus
afforded a valuable clue to the testator's mood and intention. He
mentally noted three points: the "alimentary organs with their
contents" were mentioned twice over, with a certain emphasis; they
were to be ligatured top and bottom; and the legacy was
accompanied by the expression of a wish that the legatee should not
allow his financial necessities to interfere with the conscientious
exercise of his professional duties. Wimsey chuckled. He felt he
rather liked Great-Uncle Joseph.
He got up, collected his hat, gloves, and stick, and advanced with
the will in his hand to return it to the attendant. The latter was
engaged in conversation with a young man, who seemed to be
expostulating about something.
"I'm sorry, sir," said the attendant, "but I don't suppose the other
gentleman will be very long. Ah!" He turned and saw Wimsey. "Here
is the gentleman."
The young man, whose reddish hair, long nose, and slightly sodden
eyes gave him the appearance of a dissipated fox, greeted Wimsey
with a disagreeable stare.
"What's up? Want me?" asked his lordship airily.
"Yes, sir. Very curious thing, sir; here's a gentleman enquiring for that
very same document as you've been studying, sir. I've been in this
department fifteen years, and I don't know as I ever remember such
a thing happening before."
"No," said Wimsey, "I don't suppose there's much of a run on any of
your lines as a rule."
"It's a very curious thing indeed," said the stranger, with marked
displeasure in his voice.
"Member of the family?" suggested Wimsey.
"I am a member of the family," said the foxy-faced man. "May I ask
whether you have any connection with us?"
"By all means," replied Wimsey graciously.
"I don't believe it. I don't know you."
"No, no—I meant you might ask, by all means."
The young man positively showed his teeth.
"Do you mind telling me who you are, anyhow, and why you're so
damned inquisitive about my great-uncle's will?"
Wimsey extracted a card from his case and presented it with a smile.
Mr. Robert Ferguson changed colour.
"If you would like a reference as to my respectability," went on
Wimsey affably, "Mr. Thomas Macpherson will, I am sure, be happy
to tell you about me. I am inquisitive," said his lordship—"a student
of humanity. Your cousin mentioned to me the curious clause relating
to your esteemed great-uncle's—er—stomach and appurtenances.
Curious clauses are a passion with me. I came to look it up and add
it to my collection of curious wills. I am engaged in writing a book on
the subject—Clauses and Consequences. My publishers tell me it
should enjoy a ready sale. I regret that my random jottings should
have encroached upon your doubtless far more serious studies. I
wish you a very good morning."
As he beamed his way out, Wimsey, who had quick ears, heard the
attendant informing the indignant Mr. Ferguson that he was "a very
funny gentleman—not quite all there, sir." It seemed that his
criminological fame had not penetrated to the quiet recesses of
Somerset House. "But," said Wimsey to himself, "I am sadly afraid
that Cousin Robert has been given food for thought."
Under the spur of this alarming idea, Wimsey wasted no time, but
took a taxi down to Hatton Garden, to call upon a friend of his. This
gentleman, rather curly in the nose and fleshy about the eyelids,
nevertheless came under Mr. Chesterton's definition of a nice Jew,
for his name was neither Montagu nor McDonald, but Nathan
Abrahams, and he greeted Lord Peter with a hospitality amounting to
enthusiasm.
"So pleased to see you. Sit down and have a drink. You have come
at last to select the diamonds for the future Lady Peter, eh?"
"Not yet," said Wimsey.
"No? That's too bad. You should make haste and settle down. It is
time you became a family man. Years ago we arranged I should
have the privilege of decking the bride for the happy day. That is a
promise, you know. I think of it when the fine stones pass through my
hands. I say, 'That would be the very thing for my friend Lord Peter.'
But I hear nothing, and I sell them to stupid Americans who think
only of the price and not of the beauty."
"Time enough to think of the diamonds when I've found the lady."
Mr. Abrahams threw up his hands.
"Oh, yes! And then everything will be done in a hurry! 'Quick, Mr.
Abrahams! I have fallen in love yesterday and I am being married to-
morrow.' But it may take months—years—to find and match perfect
stones. It can't be done between to-day and to-morrow. Your bride
will be married in something ready-made from the jeweller's."
"If three days are enough to choose a wife," said Wimsey, laughing,
"one day should surely be enough for a necklace."
"That is the way with Christians," replied the diamond-merchant
resignedly. "You are so casual. You do not think of the future. Three
days to choose a wife! No wonder the divorce-courts are busy. My
son Moses is being married next week. It has been arranged in the
family these ten years. Rachel Goldstein, it is. A good girl, and her
father is in a very good position. We are all very pleased, I can tell
you. Moses is a good son, a very good son, and I am taking him into
partnership."
"I congratulate you," said Wimsey heartily. "I hope they will be very
happy."
"Thank you, Lord Peter. They will be happy, I am sure. Rachel is a
sweet girl and very fond of children. And she is pretty, too. Prettiness
is not everything, but it is an advantage for a young man in these
days. It is easier for him to behave well to a pretty wife."
"True," said Wimsey. "I will bear it in mind when my time comes. To
the health of the happy pair, and may you soon be an ancestor.
Talking of ancestors, I've got an old bird here that you may be able to
tell me something about."
"Ah, yes! Always delighted to help you in any way, Lord Peter."
"This photograph was taken some thirty years ago, but you may
possibly recognise it."
Mr. Abrahams put on a pair of horn-rimmed spectacles, and
examined the portrait of Great-Uncle Joseph with serious attention.
"Oh, yes, I know him quite well. What do you want to know about
him, eh?" He shot a swift and cautious glance at Wimsey.
"Nothing to his disadvantage. He's dead, anyhow. I thought it just
possible he had been buying precious stones lately."
"It is not exactly business to give information about a customer," said
Mr. Abrahams.
"I'll tell you what I want it for," said Wimsey. He lightly sketched the
career of Great-Uncle Joseph, and went on: "You see, I looked at it
this way. When a man gets a distrust of banks, what does he do with
his money? He puts it into property of some kind. It may be land, it
may be houses—but that means rent, and more money to put into
banks. He is more likely to keep it in gold or notes, or to put it into
precious stones. Gold and notes are comparatively bulky; stones are
small. Circumstances in this case led me to think he might have
chosen stones. Unless we can discover what he did with the money,
there will be a great loss to his heirs."
"I see. Well, if it is as you say, there is no harm in telling you. I know
you to be an honourable man, and I will break my rule for you. This
gentleman, Mr. Wallace——"
"Wallace, did he call himself?"
"That was not his name? They are funny, these secretive old
gentlemen. But that is nothing unusual. Often, when they buy stones,
they are afraid of being robbed, so they give another name. Yes,
yes. Well, this Mr. Wallace used to come to see me from time to
time, and I had instructions to find diamonds for him. He was looking
for twelve big stones, all matching perfectly and of superb quality. It
took a long time to find them, you know."
"Of course."
"Yes. I supplied him with seven altogether, over a period of twenty
years or so. And other dealers supplied him also. He is well known in
this street. I found the last one for him—let me see—in last
December, I think. A beautiful stone—beautiful! He paid seven
thousand pounds for it."
"Some stone. If they were all as good as that, the collection must be
worth something."
"Worth anything. It is difficult to tell how much. As you know, the
twelve stones, all matched together, would be worth far more than
the sum of the twelve separate prices paid for the individual
diamonds."
"Naturally they would. Do you mind telling me how he was
accustomed to pay for them?"
"In Bank of England notes—always—cash on the nail. He insisted on
discount for cash," added Mr. Abrahams, with a chuckle.
"He was a Scotsman," replied Wimsey. "Well, that's clear enough.
He had a safe-deposit somewhere, no doubt. And, having collected
the stones, he made his will. That's clear as daylight, too."
"But what has become of the stones?" enquired Mr. Abrahams, with
professional anxiety.
"I think I know that too," said Wimsey. "I'm enormously obliged to
you, and so, I fancy, will his heir be."
"If they should come into the market again——" suggested Mr.
Abrahams.
"I'll see you have the handling of them," said Wimsey promptly.
"That is kind of you," said Mr. Abrahams. "Business is business.
Always delighted to oblige you. Beautiful stones—beautiful. If you
thought of being the purchaser, I would charge you a special
commission, as my friend."
"Thank you," said Wimsey, "but as yet I have no occasion for
diamonds, you know."
"Pity, pity," said Mr. Abrahams. "Well, very glad to have been of
service to you. You are not interested in rubies? No? Because I have
something very pretty here."
He thrust his hand casually into a pocket, and brought out a little
pool of crimson fire like a miniature sunset.
"Look nice in a ring, now, wouldn't it?" said Mr. Abrahams. "An
engagement ring, eh?"
Wimsey laughed, and made his escape.
He was strongly tempted to return to Scotland and attend personally
to the matter of Great-Uncle Joseph, but the thought of an important
book sale next day deterred him. There was a manuscript of Catullus
which he was passionately anxious to secure, and he never
entrusted his interests to dealers. He contented himself with sending
a wire to Thomas Macpherson:
"Advise opening up Great-uncle Joseph immediately."
The girl at the post-office repeated the message aloud and rather
doubtfully. "Quite right," said Wimsey, and dismissed the affair from
his mind.
He had great fun at the sale next day. He found a ring of dealers in
possession, happily engaged in conducting a knock-out. Having lain
low for an hour in a retired position behind a large piece of statuary,
he emerged, just as the hammer was falling upon the Catullus for a
price representing the tenth part of its value, with an overbid so
large, prompt, and sonorous that the ring gasped with a sense of
outrage. Skrymes—a dealer who had sworn an eternal enmity to
Wimsey, on account of a previous little encounter over a Justinian—
pulled himself together and offered a fifty-pound advance. Wimsey
promptly doubled his bid. Skrymes overbid him fifty again. Wimsey
instantly jumped another hundred, in the tone of a man prepared to
go on till Doomsday. Skrymes scowled and was silent. Somebody
raised it fifty more; Wimsey made it guineas and the hammer fell.
Encouraged by this success, Wimsey, feeling that his hand was in,
romped happily into the bidding for the next lot, a Hypnerotomachia
which he already possessed, and for which he felt no desire
whatever. Skrymes, annoyed by his defeat, set his teeth, determining
that, if Wimsey was in the bidding mood, he should pay through the
nose for his rashness. Wimsey, entering into the spirit of the thing,
skied the bidding with enthusiasm. The dealers, knowing his
reputation as a collector, and fancying that there must be some
special excellence about the book that they had failed to observe,
joined in whole-heartedly, and the fun became fast and furious.
Eventually they all dropped out again, leaving Skrymes and Wimsey
in together. At which point Wimsey, observing a note of hesitation in
the dealer's voice, neatly extricated himself and left Mr. Skrymes with
the baby. After this disaster, the ring became sulky and demoralised
and refused to bid at all, and a timid little outsider, suddenly flinging
himself into the arena, became the owner of a fine fourteenth-
century missal at bargain price. Crimson with excitement and
surprise, he paid for his purchase and ran out of the room like a
rabbit, hugging the missal as though he expected to have it snatched
from him. Wimsey thereupon set himself seriously to acquire a few
fine early printed books, and, having accomplished this, retired,
covered with laurels and hatred.
After this delightful and satisfying day, he felt vaguely hurt at
receiving no ecstatic telegram from Macpherson. He refused to
imagine that his deductions had been wrong, and supposed rather
that the rapture of Macpherson was too great to be confined to
telegraphic expression and would come next day by post. However,
at eleven next morning the telegram arrived. It said:
"Just got your wire what does it mean great-uncle
stolen last night burglar escaped please write fully."
Wimsey committed himself to a brief comment in language usually
confined to the soldiery. Robert had undoubtedly got Great-Uncle
Joseph, and, even if they could trace the burglary to him, the legacy
was by this time gone for ever. He had never felt so furiously
helpless. He even cursed the Catullus, which had kept him from
going north and dealing with the matter personally.
While he was meditating what to do, a second telegram was brought
in. It ran:
"Great-uncle's bottle found broken in fleet dropped by
burglar in flight contents gone what next."
Wimsey pondered this.
"Of course," he said, "if the thief simply emptied the bottle and put
Great-Uncle in his pocket, we're done. Or if he's simply emptied
Great-Uncle and put the contents in his pocket, we're done. But
'dropped in flight' sounds rather as though Great-Uncle had gone
overboard lock, stock, and barrel. Why can't the fool of a Scotsman
put a few more details into his wires? It'd only cost him a penny or
two. I suppose I'd better go up myself. Meanwhile a little healthy
occupation won't hurt him."