We already know how to create Rest API in Liferay 7 (JAX-RS Web Services). Today we will see how we can use spring and add objects in Liferay databases. Here we will create a Rest service that will add data in Liferay database. Before reading this blog it is highly recommended to read how to create Rest API in Liferay 7 (JAX-RS Web Services). Here i am using Liferay 7.3.
So lets start this step by step :-
Step 1:- Create a simple Rest Portlet
Create a simple Liferay module Project and select Rest Template provide class name and package name and Click Finish. Now open your java file and paste this :-
EmployeeRestApplication.java
Step 2:- Add Dependencies in build.gradle
Now open build.gradle and paste the dependencies :-
build.gradle
Step 3:- Create Employee Bean
Create Employee.java that contain setter and getters which can parse Json to Employee object and used with @RequestBody
Employee.java
Step 4:- Test your API
Deploy your project and test the API using postman
No comments:
Post a Comment