Spring web-based admin tool with CRUD - java

In PHP & Symfony world there is a tool called Sonata Admin https://sonata-project.org/ based on AdminLTE template, that is all-in-one admin tool with login, menu configuration, and what is most important - database tables HTML grid CRUD generators.
The tool saves you tons of efforts by avoiding you writing boilerplate code, moreover, there might be a scenario that you would write zero code.
We need the same but for Java and Spring stack. Any recommendations?

Take a look at JHipster project https://www.jhipster.tech/
With it you can create Spring Boot+Angular/React/Vue based applications. It provides some cool tools for generating CRUD entities by scaffolding.

https://www.javatpoint.com/spring-mvc-crud-example contains an example of how to create a Spring MVC CRUD there are plenty more examples of various spring project (This particular falls under Spring MVC).
This is not a ready-made CRUD, but a way how you could quickly implement one.
https://spring.io/guides/gs/crud-with-vaadin/ is also worth checking.
Although there are few project like spring batch admin (For batch administration), or Spring boot admin (Monitoring spring boot applications), which provides a UI, mainly spring project provides a simple programmatically way of plugging in what's needed.
It's a plug & play kind of framework which targets various aspects of an enterprise application. Chances of finding a ready-made UI app would be more on GitHub rather than a specific spring plugin.

Simple answer to your question is No spring does not provide any tool for that but spring gives you the functionalities that can reduce your work but not with zero coding.
example:
Using Spring Data JPA there is an Interface name curdRepository which
takes care of the curd Operations we dont need to implement the methods
for Curd Spring takes care of Curd operation.
Spring Security Provides the login configuration with the login form and logout mechanism.
You can use spring boot or just visit the https://start.spring.io/ it will initialize the spring project with the dependencies you need

Related

Spring features and significance?

Spring empowers POJO based programming.
It offers support for MVC out of the box
wires up code in less time.
How does it support layered architecture?
provides an abstraction layer to simplify development process(why is this a benefit and how does spring handle this?)
How does spring do that?
I read a lot of articles talking about the advantages of spring. But none of them explain in theory i.e. in words not code, how spring does that?
for example, one of the advantages says it empowers POJO programming? we can do that with plain java too, why is that a benefit or what's the opposite of POJO?
Kindly request everyone to address those 3 questions. THanks
in short:
spring was created a long time ago. it was probably compared to ejb2 that needed more setup code. POJO vs EJB vs EJB 3 Also spring does support pojos for example as return value in MVC-controllers. pojos dont have external dependencies so your application stays portable (non-functional requirement of an application).
yes you can easily (my opinion) create web applications.
at its core spring provides a container in which bean definitions are stored. when a service is requested that needs a dependecy, spring can look up whether it has a bean definition for that dependency, construct an instance of that bean and inject it in that service. That way you dont need to manually instantiate your service.
for example in web applications spring has abstractions for controllers, services and repositories. typically an application provides controllers so that caller can use your api. controllers should call services that handle your business logic. and services can call repositories that persist your data. that way you have a layered flow:
controllers --> services --> repository
this has the advantage that when you change e.g. your repository you dont have to make changes to your controllers.
spring provides many abstractions for common problems out-of-the-box (e.g. spring security) and empowers convention-over-configuration. That way you can reduce boilerplate code. less code -> less probability for a developer to make a mistake.
e.g. spring-security-oauth2: you can just set some properties in a .properties file and spring autoconfigures beans that solve the validation of an oauth-token when a user requests one of your controllers.

Which of these approaches is better for breaking Spring Boot applications into three tiers?

We are trying to split a big monolithic J2EE application into a set of modules to provide unified business logic for all web application clients.
Our goal is to have smaller and more specialized business modules that can be used in any combination by many distinct web applications. This way we expect the applications get easier to maintain individually (compared to the now heavily coupled monolithic one).
We are planning to arrange it like the following diagram:
Where Web Apps call module services on the upper layer to handle business logic through method calls (RMI was the intended protocol but we are open to other options).
J2EE makes it easy to arrange services on three tiers like this through EJB remote beans.
But we are also trying to setup these modules as spring boot applications (using the Spring Boot JPA Starter) because it makes development much more convenient.
My initial plan was to implement the modules with Spring Boot and expose a thin layer of EJB beans as proxies to spring beans with the actual implementation of the service. EJB beans would have spring beans injected using the SpringBeanAutowiringInterceptor class as in spring v4 documentation.
But since this kind of integration was removed from spring v5 I don't know how to proceed.
They are also considering "EJB as an effectively deprecated technology now" as stated in the issue above. But for my use case I can't find a good enough alternative.
So far I have thought of the following options:
Using a custom interceptor as the issue suggests. But it looks like reinventing a discarded old wheel (if that analogy makes any sense).
Spring remoting is an alternative but it's challenging to make it work with Wildfly JNDI for RMI configuration and trying to looks like re-implementing EJB remoting.
Spring Integration I think will add too much complexity and overhead for this simple task.
Message based integration (JMS, MQTT, etc...) may not fit well because of the synchronous nature of what we are trying to achieve.
REST API calls would add a lot of boilerplate code (for serialization and deserialization of objects into JSON, endpoints configuration and so on) and also add some ovehead because the HTTP handling.
Our goals, in this order of priority, are:
Make this integration as solid and fail-proof as possible.
Make calls to business logic from the web layer to the service layer as simple as possible.
Have as little overhead as possible.
With all that said which of those five options mentioned (or maybe another one I haven't considered) would be the best way and why?

Is spring MVC purposed for web pages?

I want to build a server for my android application.
My application lets users register and allows each user to request a list of all users registered to my application, so my server will be mainly in charge of receiving data from a user, updating the database, and sending data back to user on request.
Since I've never built a server I looked into what would be the ideal way to achieve my goals and after some reading I've found that Spring would be the right way to go, But I also found that there are all kinds of springs.
Eventually I've narrowed my options down to Spring MVC and spring Boot,
I've read that spring boot is a good start but I also read that spring boot does all the configurations for you and I want to really know how stuff works so I fear that spring boot will do all the work for me , So I thought of maybe using spring MVC but I couldn't completely figure out if Spring MVC would be good to achieve my goals or if it's mainly used for building web pages
So what would be the best suitable spring to use ?
I would prefer Spring boot. It's not just about it doing all the configuration for you. It's about Spring saving you from writing a lot of boilerplate code (you still have to do a fair bit of configuration though). Plus, it will be easy to spin up the app and test it locally (you can even test it with local file based h2 database, meaning you don't need to install any database into your machine).
Adding Spring Data JPA dependency with Spring boot will take care of persistent layer as well. And if you want to write jsp or html pages then I would recommend having a look at this thymeleaf example.
Here's the sample CRUD application I have developed with Spring boot and here's my own blog about it.
Spring MVC stands for model,view,controller. View, in general is something which is returned after your business logic has been executed and mainly suggests webpages. Spring Boot would be the easiest way to set up your server for the application. However, if you want to know how things work you can go with the basic spring. Spring, too provided classes like JdbcTemplate to reduce your boilerplate code, however it forces you to configure things yourself.
You do not have the comfort of annotating a resource and watching as the magic happens. If you want to speed up setting up a server and make things less complex go for Spring Boot.

AngularJS + Spring Project architecture

I am planning to start a project and I am looking for the best approach to make a RIA application using AngularJS.
Right know I am pretty sure of those technologies:
AngularJS (+ bootstrap CSS) for the client UI, logic and server
requests.
Spring for bootstrapping the server business logic.
Hibernate + MySQL for persistent data access
Jersey for the Restful web service API.
Spring Security for url and data protection over authentication.
The only piece I feel is not ok is that my application will not be the typical one page app, because it will be large and I want to break it into multiple one page apps, some protected and others public. To serve every index.html I want another technology like Spring MVC, making those small one page apps secure for this points, and also not allowing the access to some resources.
¿Do you think this is a good approach or you would change any of this technologies (like supressing jersey/Spring MVC redundant dependencies)?
i think that in general your aprroach is a good one, but maybe you could use the webapp generator yeoman with the JHispster, a java web app generator.
Or if you don't like the ideia you could add to your data access layer the Spring-Data-JPA, because you will avoid to write the boilerplate code.

Swing application with Hibernate and Spring

Can we use Spring as Controller and Hibernate as ORM tool for an application with User Interface SWING??
If yes how??
How will be its directory would appear. How all injections will takes place. For simplicity maintaining a environment for saving Text fields input into DATABASE using Hibernate.
Spring could not be used as Controller in desktop application (Spring MVC is a web framework), but it can be used for features such as autowiring.
However Spring and Swing does not play well together, my last attempt failed due to really inconvinient configuration and lots of overhead code.
Some time ago there was a project called Spring Rich Client, but seems to be abandoned.
Anyway - internet is full of examples of using Swing with Spring, but you have to know that this pair is "not that popular".
Spring: How to Create Decoupled Swing Components
SPRING HAND IN HAND WITH SWING APPLICATION FRAMEWORK
Using pair of Hibernate and Spring is not different than in web-application case.
No. You cannot use Spring as a controller. But you can use core Spring container for using in Dao and Service layer. Hibernate for using Object mapping with Database Table.

Categories