Intermediate level Java course lab
Spring Boot is an easy to framework. Here, JPA framework shall be used to store and retrieve data in a relational database. This will be coupled with an in-memory database H2 for the ease of database connectivity. This is important topic for Pivotal Spring Professional Certification for core java training in Delhi in the current IT industry.
II. Software Tools
This lab is provided with the following tools, however any newer versions can be used for accomplishing this lab:
- Java platform – version 8.151
- IntelliJ IDE – version 2017.2.6
- Maven for dependency management – version 3
These software tools are most widely used in IT industry for advance java training in Delhi and for java projects.
The purpose of this lab is to create a simple web application which allows a user to register their information and later retrieve it as well. We are going to achieve this through a RESTful spring boot application because it is a great library which hides a lot of webmvc integration and allows the programmer to focus on code only. This lab help students gain more knowledge to prepare for java certification in Delhi.
IV. Lab Instructions
Maven is used here for dependency management here. It is very useful to maintain a proper code structure as well.
Add the following dependencies.
This is an excellent library that allows visualisation of RESTful calls. It also provides the CURL equivalent command in case that is preferable. It is a good example of live documentation of the code as well. It is important library used for Java training in Delhi.
On running the application now, Swagger is being rendered /swagger-ui.html endpoint.
Create the User JPA entity by annotating it with @Entity as follows:
The @NonNull validations ensure that the Entity cannot be created with null values and will throw up runtime ConstraintViolationException when trying to insert a record with null values.
JPA repository is very short and simple with a method for querying. We don’t need to write more code as spring takes care of it. This will create proper SQL queries behind the scenes.
This class allows us to add the REST endpoints through which we can send and retrieve user information. Again, we are using boilerplate Spring REST code peppered with Lombok annotations.
- Run the application either through maven or IntelliJ Application run config.
- Swagger UI shows the controller methods.
- Register a user through the UI
- Check the response has status code 200.
- Now, retrieve the saved user.
- Check the response.
Codec Networks provides IT Trainings from EC Council CEH ECSA, LPT, CHFI, Network Security, Penetration Testing, ISACA, ISC2, PECB ISO 27001LA LI, Cisco Networking CCNA CCNP, Linux Administration RHCE, Prog Languages JAVA, Advanced Java, android development. We also offer B2B Industry Solutions and Services in IT | Information|Cyber Security in Delhi NCR India.