Once you have created your application, you will want to create entities. For example, you might want to create the Book entity, which represents a book. For this, you will need:
The "entity" sub-generator will create all the necessary files, and provide a CRUD front-end to the entity.
If you created your application with MongoDB instead of a more classical SQL/JPA solution, JHipster will still generate your entity correctly (you will have a MongoDB document instead of a JPA entity).
Let's create the "Book" entity, which has a title, description, publication date, and price.
Create the entity with the sub-generator. For instance, for creating the "Book" entity, please type:
yo jhipster:entity book
You must answer the next questions, asking for each field name and type. For example, the "Book" has:
This will generate all the required files.
Run the generated test suite, with mvn test
, which will test the new Book entity.
Launch the application (for example with mvn spring-boot:run
), log in and select the "Book"
entity in the "entities" menu.
Check the database table, to see if your data is correctly inserted.
The generated files contain all the basic CRUD operations, and don't need to be modified if your needs are simple.
If you want to modify the generated code or the database schema, you should follow our development guide
If you want some more complex business behaviors, you might need to add a Spring @Service
class, using the service sub-generator.
Your generated CRUD page should look like this: