Use React and Spring Boot to Build a Simple CRUD App

jubbsy1

No I just mean literally why are you passing Event into a singleton?

Matt Raible

No reason, really. It was just a convenient way to convert a single object into a Set.

Dave Howson

Thank you for sharing about that PUT request. I was wondering why my HTTP command didn’t work. :slight_smile:

Pushkar Singh

A minor suggestion; Lombok’s @Slf4j annotation can be used as well to get access to ‘Logger log’ and then be used directly as:
log.error(“Something is wrong here”);

Matt Raible

Thanks for the tip! I recently discovered @Log4j2 myself. It looks like Lombok supports a plethora of Log annotations.

disqus_NMX

In your GroupController.java, it looks like Intellij added:
import javax.Event;
when you really wanted:
import com.okta.developer.jugtours.model.Event;
or even better:
import com.okta.developer.jugtours.model.*;

Also make sure you have the @Builder annotation at the top of your Event class.

PS - Thanks Matt, that was a sweet tutorial.

Christian Goudreau

Realy neat tutorial! I’m having trouble doing this with WebFluxSecurity and Angular on port 4200, could you offer some guidance?

Thanks!

Matt Raible

Hello Christian,

Since your question isn’t related to this tutorial, can you please ask your question on our developer forums. Please include steps to reproduce the problem you’re seeing. I’ll do my best to answer your questions there.

Matt Raible

You are correct. The @PutMapping should have an ID in it’s path:


@PutMapping("/group/{id}")

I’ll get this post and example updated shortly.

Jigisha Aryya

How do I filter the records for every user and show a personalized home page?

Matt Raible

Hello Jigisha,

Your question doesn’t seem to be related to this tutorial. I’d suggest trying to make it work on your own and posting any issues you have to Stack Overflow. If you run into issues with Okta specifically, tag it with “okta” and my team will get a notification.

Fabian Wenzel

Thank you for the tutorial, it helped me alot.

I try to build my own react+spring application and i am struggling when it comes to routing.
I can easily navigate to the index page ("/"), and also navigate to the groups ("/groups") by clicking the link on the index page.
When it comes to manual navigation by typing (“http://localhost:8080/groups”), it returns a 404.
I tried it in your application and in mine, both times the same error.
How can i access any path directly, without the need to access the index page first?
Should it be possible to do that, or is this feature not supported?

Kacper

Hi I have an issue with login. Everything works fine when I login through pc browser but when i hit login button in google chrome on android smartphone, i get 400 error invalid_request. The ‘redirect_uri’ parameter must be an absolute URI that is whitelisted in the client app settings. I have checked my security code with yours and it seems to be ok.

Matt Raible

If you can inspect the URL in your browser, you can see what redirect_uri parameter it’s trying to send. Add this URI to your app, and it should fix the problem.

Matt Raible

This is likely happening because there isn’t anything on the Spring Boot side of things that redirects from 404s back to the index.html. Single Page Applications with Spring Boot seems to have a solution that will solve the problem. Please try it and let me know if it works.

Kacper

It works! Thank you!

Fabian Wenzel

Hi Matt, thank you for your answer and recommendation.

The approach shown at the other tutorial is not working as intended, when using frontend-maven-plugin.
I found another workaround, by just forwarding all relevant paths to the index.html:
Example Implementation

Adding all relevant paths to the @RequestMapping annotation, lets you easily configure all allowed paths. Now you can directly access any specified uri and get the corresponding view from react.
In my opinion, it is more convenient this way.

Công Trần

Thanks for the tutorial, it helped me alot.
But how to deploy this to heroku?

disqus_MWH2ssKIuT

Great tutorial, thanks!

Matt Raible

See my Bootiful Development with Spring Boot and React blog post. It has a link to a heroku.sh script you can use to deploy both Spring Boot and React to Heroku.