Need advice? What to choose Servlets or Spring MVC? - servlets

I have an application in mind which I want to develop. I am targeting the application for a big user base, consider it as a social app. But I am not
sure whether to write it with Servlets or Spring MVC.
I have a good grip on Servlets, it would be easy for me to develop, but when it comes to Spring I am still novice.
I am not clear what difference would it make if the app is developed on Servlets rather than Spring MVC.
Scalability or some factors like that?
Any advice would be appreciated. Thanks

It might take you some time to learn Spring but..., once you do, it will provide powerful tools to code.

Its always good to go for Spring framework as it provides:
Dependency Injection support
Spring MVC: easy to customize
Data access support
Spring Security
AOP support etc..
Clearly, Spring provides more functionality than servlets. But if your app is very simple enough, you can go for Servlets.

Related

Approach for creating RestFul web services in Spring?

I want to develop RestFul web service using Spring. When I googled, I found that it can be done in two ways. One way is to use Spring's own Spring MVC and the other way is to use Jersey (or any other JAX-RS implementation) that provides support for Spring. I would like to know which approach would be better.
There’s something to be said for the cleanliness that is inherent to the JAX-RS spec. Whereas the Spring MVC approach is sufficient, JAX-RS is targeted solely to implementing REST APIs. Spring MVC isn’t built for that purpose alone and personally, I think it shows. Sometimes it can be a bit verbose or confusing.
For example, if you omit a method on a Spring MVC REST controller, Spring MVC happily assumes you want to have this endpoint available for all HTTP methods. For MVC purposes, this might be okay, for REST, this is not. And if you add the method to the #RequestMapping, you suddenly can’t use the terse notation and need to explicitly declare the value parameter on the notation. Same thing with setting explicit MIME types for an endpoint.
At the moment, I haven’t found anything that Spring MVC can do for REST which JAX-RS couldn’t.
P.S. It's the developer's choice. Technically one can build the same web service with both.

Spring MVC or Spring Boot [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
For a large company (web) project, do you recommend using Spring MVC or Spring-Boot?
Spring-Boot, in terms of configuration, is very easy compared to Spring MVC.
I wonder if I use Spring-Boot can have the same advantages of Spring MVC?
What do you recommend?
My personal advice is to definitely use Spring Boot for many reasons.
The first is that Boot is the "future of Spring". That means that with Boot
you can benefit from many commitments of the Spring community. Most of the
Spring projects today are completely
integrated with Boot, even the community starts to develop many
applications based on Boot. For example for managing and monitoring.
I can suggest to see Spring Boot Admin
With Spring Boot you can benefit from very nice and useful features such as
actuator and remote shell for managing and monitoring, that
improves your application with production ready features that are very
useful.
Very nice and powerful properties and configuration controls - you
can configure your application with application.properties/yml
and extend the boot in a very simple and impressive way, even the
management in terms of overriding is very powerful.
It is one of the first micro-service ready platforms, and in my opinion
nowadays it is the best! Even if you don't build a micro-service
project with boot you can benefit of using a modern approach in which
you have a auto-consistent jar that can benefit from all the features
that I described above or if you prefer you can impose the packaging
as a classical war and deploy your war in any of the containers that
you want.
Use of an intelligent and convention over configuration approach that
reduces the startup and configuration phase of your
project significantly. In fact you have a set of starter Maven or Gradle dependencies
that simplify the dependency management. Then with the
auto-configuration characteristic you can benefit from a lot of
standard configurations, that are introduced through the Conditional Configuration framework
in Spring 4. You can override it with your specific
configurations just defining your bean according with the
convention that you can see in the auto-configure JAR of the Boot
dependency. Remember that Spring is open-source and you can see the code. Also the documentation in my opinion is good.
Spring initializer is a cool tool attainable at this link:
https://start.spring.io/ is a very cool tool just to create your project in a very fast way.
I hope that this reflection can help you decide what is the best solution.
Spring Boot uses Spring MVC! It's just autoconfigured and ready to use when you import the spring-boot-starter-web jar. So you'd basically are talking about whether to use Spring Boot or manually setup your Spring Application...
You can definitely go for Spring Boot. We have already started using Spring Boot for building enterprise application. It has lot of advantages, listing few below here:
Your project configuration will be pretty simple. No need to maintain XML file, all you need to know is how efficiently you can use application.properties file.
Gives lot of default implementation, for instance if you need to send an email, it provides default implementation of JavaMailSender
Spring Hibernate and JPA integration will be pretty simple.
Like this there are many, you can explore based on your needs.
You can use Spring MVC with spring boot as #kryger said, they are non exclusive between them, and the configuration will be easier, also I recommend you to use http://www.thymeleaf.org/ which is template framework. Working with that is like working with JSP but thymeleaf integrates seamlessly with HTML, so your code will look very clean and you can add a lot of useful features.
I think Spring Boot is more useful than the MVC, as it has many advantages and inbuilt features which make it more reliable than MVC. In Spring Boot most of the things are auto configured and there is no need of writing those xml as we do in the MVC, which can save time.
Spring Boot bundles a war file with server run-time like Tomcat. This allows easy distribution and deployment of web applications. As the industry is moving towards container based deployments, Spring Boot is useful in this context as well.
Spring MVC is web application framework. While you can do everything in Spring without Spring Boot, but Spring Boot helps you get things done faster.
Spring boot simplifies your Spring dependencies, no more version collisions,
can be run straight from a command line without an application container,
build more with less code - no need for XML, not even web.xml, auto-configuration, useful tools for running in production, database initialization, environment specific config files, collecting metrics.
Basics of Spring Boot can be found here

Using Spring DI concepts in Eclipse RCP application

I have been wondering how can we use spring in RCP applications. There are things like google Guice which is been used widely for DI in RCP(at least in place where i work).
As a fan of Spring frame work, i tried it in using Spring for DI.
As an example i spring injection for simple classes,Handlers,views and other stuffs which are the part eclipse RCP with customization.
I am in what way we can make spring as a fully supporting DI framework in RCP.
Please if some one has tried please help me to achieve this idea.
As a start up i have developed simple RCP application using spring DI.

Backbone and spring mvc

Hi I am just starting to learn backbone.js and now I am trying to integrate it with spring mvc, I looked everywhere for a simple example using the two to get an idea how it works but all I found was a few complex examples which I tried and failed to understand.Could you please provide me examples and help me do a simple hello world example using Backbonejs and spring mvc.
If you are familliar with the usage of Spring MVC, you can try using the "jackson" extension on your controllers. Jackson has the ability to turn your data requests into replies that are in the form of Data Transfer Objects (specifically JSON).
Since Backbone.js will handle all of your frontend needs, it is alright to use only the Model and Controller parts of the Spring MVC framework. Backbone.js's models will therefore consume your jackson integrated Spring MVC rest service, and can the be rendered in Backbone Views.
Yo can start with Spring Getting Started Guide "Consuming a RESTful Web Service with Backbone.js"
Or go for a full stack like RESThub with the "Spring Stack tutorial".

Spring MVC -> Wicket Integration

I'm working on porting part of an existing Spring MVC application over to Wicket.
I used the wicket-spring library to get the initial integration working, but now I'm stuck with the best way to integrate my Spring Security implementation.
I was wondering if anyone could give me some advice on the best way to handle this.
Did you check Wicket / Swarm / Spring Security How-to?

Resources