How to fetch data in Spring Boot from table of Angular7 - spring-boot

I created data table in angular and taking order input from customer. Customer will enter order data and click on submit. What I want that when customer will click on submit button that time this order data will be send to the my spring boot application and print.
How can I fetch this data in spring boot and display using get and post method? I am new to Angular and Spring Boot.

You can take a reference from below link how to create API in spring boot and how to call it from angular.
https://www.devglan.com/spring-boot/spring-boot-angular-example

When you send a array list data from angular to spring boot using post method then in spring boot you can receive same array list using post method not get method..

Related

Custom aggregated query with spring boot data REST

I'm pretty new to Spring Boot and Spring Data Rest and HATEOAS. I'm able to create a REST API with CRUD capability on an entity (say Device, entity having a few properties, including one called manufacturer), and interact with the API (get/add/update/delete/patch device) "out of the Spring Boot box".
I now want to call an API endpoint to get an aggregated view of the device repository that, in short, returns the result of the query select manufacturer, count(*) from devices group by manufacturer. Is this doable with spring data rest or it needs to be done with JPA? or should I define a specific entity having these two fields (device_manufacturer, count)?
Thanks

How to integrate swagger with spring cloud function

I have one spring boot application having three spring cloud function which I am able to execute via postman or curl successfully .Now my next step is to add swagger documentation for the same. I have followed all configuration that we do to add swagger with normal spring boot project. And it is up and running but problem is that my functions URL are not listed in swagger since Request Mapping or API operations annotations are not getting picked up maybe those are just functions not a controller that's y. So if someone could help how to integrate so i can document all cloud functions that I am creating.

How to store request data and reponse data into database in spring boot application

I am working on to store request data and response data if there any exceptions encountered while sending response back to client I need to store the exception also.
My DB table will ID,RequestData,ResponseData,Exception,TimeTakenToRespond
lets say I have endpoint called /athenticateUser so my input data would be
RequestData :{"username":"mate","password":"swamy"}
ResponseData :{"FirstName":"mate","LastName":"swamy","Email":"manteswamy#gmail.com"}
Like the above way I need to store all the request data and response data if any exception while sending response back to client that also we need store and the web service time taken respond.
As I am beginner to spring boot please guide step by step
Though you can write Interceptors, Filters etc for this. But don't do it.
Please try to use Spring Boot feature Actuator for tracing. It provides HTTP request logging out of the box.
There's an endpoint mapped to /trace or /actuator/httptrace which will show you last 100 HTTP requests. You can customize it to log each request, or write to a DB.
You will need spring-boot-starter-actuator dependency.
You can also whitelist endpoints.
For the guide step by step, you can check this actuator tutorial.
You can do it by using spring boot actuator httptrace..
add below dependency:
implementation('org.springframework.boot:spring-boot-starter-actuator')
Look at this step by step guide..
The Spring-boot actuator doesn't support getting the request/response bodies, they even removed some mechanisms to do it.
Here's a blog post on how to do it with a Filter.

communication with two web services using came and spring boot

Hi I am new to camel and I want to communication with two web services my requirement is :
array of object pass to one web service
array[0] have school details so it will save in database using spring rest call("/register")
array[1] have admin details so need to save in admin database using other spring rest service ("/register-admin") and generate username and password and return
I am trying to do that by using ("rest:post:register") but camel and spring boot has started on different port so 404 getting
I used ("jetty:{uri}") also but it is not working and if it will work then how we will pass object via request body
please help me to solve
thank you very much in advance
You can try use the http4 component with bridgeEndpoint=true, like this.
.toD("http4//yourUrl?bridgeEndpoint=true");
I always do this way.

Spring Boot REST JSP

I have a working Spring BOOT application that has a custom security provider and REST API controllers. I would also like to add a GUI interface to the application for access from a browser through jsps, html, and a login page which uses my existing custom security provider I used with the REST APIs. Maybe using Spring MVC since that is needed for the REST API support. I could not find a single example of doing this on the web. Also, I do NOT want to use any web XML based configuration files - as I am currently only using Java config for the implementation of the REST APIs. I am also currently using SSL for REST API access through SSL in a Jetty embedded web container. Please help if you can? Thanks in advanced.
Paul there is a rather large amount of information on view technologies that are compatible with Spring BOOT. You need to decide what you want to use and do relevant research for it.
As a guiding hand here check this page out for just one of the many types:
http://kielczewski.eu/2014/04/spring-boot-mvc-application/
You may follow this procedure :
lets assume that u have an endpoint for which you need both REST and view controllers,your REST endpoint exposes your data in JSON as RESTController and your view Endpoint returns the view name as Simple old controller.
lets say your base url is at localhost:8080 and your endpoint of interest is /students
you could have both in same application but at different endpoints like this :
REST : localhost:8080/api/v1/students -- exposes json
VIEW : localhost:8080/students -- returns a view
hope this make clear ..

Resources