Application generation with import-jdl

In this section, we'll generate our applications using the JDL we just created.

Run the following command in the e-commerce-app folder:

> cd e-commerce-app
// delete the store folder so that we have better diff when
// new app is generated
> rm -rf store

> jhipster import-jdl app.jdl --skip-git
The --skip-ui-grouping flag can be used to disable the client-side entity-component grouping behavior for microservices that were introduced in JHipster 5.x. This grouping behavior is useful when you have entities with the same name in different services.

JHipster will start creating applications and entities in a parallel process to speed things up. If you would like the process to be more interactive so that JHipster will ask about overwriting the modified files, pass the --interactive flag to the preceding command. JHipster then asks whether you want to overwrite the conflicting files or use your existing ones, as well as a few other options. Users can use any one of the desired options. We will use "a", which means that it will overwrite everything.

This prompt is extremely useful if you have a lot of custom code written on your application. You can choose the appropriate option to get the desired result. You can also use Git for the same purpose.

If you had the monolithic application in the e-commerce-app folder, this will overwrite all the customizations we made in our monolithic application. We can easily bring them back into this branch by cherry-picking the required changes from our master branch using Git. You can follow a similar approach to the one we looked at in Chapter 5, Customization and Further Development, for that. Once all the changes have been applied, we can merge this branch back into the master. You will have to do the same for any entity files that have been modified as well:

Entity Product generated successfully.
Entity ProductCategory generated successfully.
Entity Customer generated successfully.
Entity ProductOrder generated successfully.
Entity OrderItem generated successfully.
Entity Invoice generated successfully.
Entity Shipment generated successfully.
Entity Notification generated successfully.
INFO! Congratulations, JHipster execution is complete!
INFO! App: child process exited with code 0

You will see the preceding output when our microservice application is generated. JHipster will automatically commit the generated files to Git. If you wish to do this step yourself, you can do so by providing the skip-git flag during execution, for example, with the help of the jhipster import-jdl app.jdl --skip-git command, like we've done here, and executing the steps manually.

Don't forget to commit the changes in each of the services and gateways. You could also init the entire e-commerce-app folder as a git source if you like by running git init:

> cd e-commerce-app
> git init
> git add invoice/
> git commit -m "invoice application generated using JDL"
> git add notification/
> git commit -m "notification application generated using JDL"
// Manually compare and unstage files from store that you do not want
// overridden
// Cherry-pick required changes done earlier
> git add --all
> git commit -m "store application converted to gateway using JDL"

If something goes wrong during cherry-picking, don't worry – you can always copy the app.jdl file to a new folder and run the jhipster import-jdl command to generate fresh applications and compare them to see what went wrong.

We won't need the code changes we made for Heroku deployment anymore so we can safely override them. The security changes we made for the Invoice entities will also need to be refactored a bit since the relationships have changed now. This will be one of your tasks for the next steps to pursue after finishing the book

Next, we will take a look at the generated code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.119.199