Why use Spring Boot rather than Spring Boot-less? [closed] - spring

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 7 years ago.
Improve this question
I'm confused why should i use Spring Boot for my next project? Is Spring Boot as powerful as Spring Boot-less? Or there is something you can't do with Spring Boot.

Spring Boot is opinionated Spring setup with batteries included. If you use it, you will waste less time on non-features because you will be getting quite a few things for free. List of advantages that I've observed compared to classical Spring setup (surely there are more, check the Spring Boot website):
dependency management - versions of commonly used libraries are pre-selected and grouped in different starter POMs that you can include in your project. By selecting one Spring Boot version you are implicitly selecting dozens of dependencies that you would have to otherwise select and harmonize yourself
auto-configuration - you do not have to manually configure dispatcher servlet, static resource mappings, property source loader, message converters etc.
advanced externalized configuration - there is a large list of bean properties that can be configured through application.properties file without touching java or xml config
"production ready" features - you get health checking, application and jvm metrics, jmx via http and a few more things for free
runnable jars - you can package your application as a runnable jar with embedded tomcat included so it presents a self-contained deployment unit
I haven't observed any disadvantages, it's just Spring after all. You can build anything that you could build with "vanilla" Spring, only faster.

Here is my simple explanation:
Without Spring Boot, one will have to put the correct versions of all the dependencies in the build configuration file (e.g. pom.xml) and configure all the beans manually.
This seems like a lot of non-functional task for normal projects. Hence, Spring Boot does these automatically, assuming some conventions. For example, if you just include spring-boot-starter-web dependency in your pom.xml, a web application will be automatically configured by assuming default conventions.
What makes it more interesting is that the pieces of the default configuration can be very easily overridden.
Going through a couple of official guides would give more insight on Spring Boot. In summary, unless an application is abnormal enough, people seem to be preferring Spring Boot nowadays.
Coming to power, Spring Boot could be seen as just a configuration layer. So, everything possible in Spring should also be possible using Spring Boot.

Related

Convert project from Spring framework to Spring boot

I have a set of projects in Spring framework and I have to Find the ones which can be converted to Spring boot.
Is there anything that is related to Spring framework and cannot be converted to spring boot ? In my research, I Could not Find something like that.
But does anyone know something, like a dependency, which would force the project to stay in Spring framework ?
Spring Boot uses the Spring Framework as a foundation and improvises on it. It simplifies Spring dependencies and runs applications straight from a command line. Spring Boot provides several features to help manage enterprise applications easily. Spring Boot is not a replacement for the Spring, but it’s a tool for working faster and easier on Spring applications. It simplifies much of the architecture by adding a layer that helps automate configuration and deployment while making it easier to add new features.
Most of the changes for migrating Spring Framework application to Spring Boot are related to configurations.This migration will have minimal impact on the application code or other custom components.Spring Boot brings a number of advantages to the development.
It simplifies Spring dependencies by taking the opinionated view.
Spring Boot provides a preconfigured set of technologies/framework to reduces error-prone configuration so we as a developer focused on building our business logic and not thinking of project setup.
You really don’t need those big XML configurations for your project.
Embed Tomcat, Jetty or Undertow directly.
Provide opinionated Maven POM to simplify your configurations.
Application metrics and health check using actuator module.
Externalization of the configuration files.
Good to refer this for migrating from Spring to Spring Boot application: https://www.javadevjournal.com/spring-boot/migrating-from-spring-to-spring-boot/

What is meant by Spring boot follows “Opinionated Defaults Configuration” Approach?

I have just started learning spring boot . In its official page I found out this term and I did not understand that what actually it meant in Spring boot context.
Spring Boot just decides on a set of default configured beans which you can override if you want.
For example if you include the spring boot starter pom for jpa, you'll get autoconfigured for you an in memory database, a hibernate entity manager, and a simple datasource. This is an example of an opinionated (Spring's opinion that it's a good starting point) default configuration that you can override.
See https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-replacing-auto-configuration
Spring Boot, is Spring on steroids if you will. It's a great way to get started very quickly with almost the entire Spring stack. I'll try to summarize as what "Opinionated Defaults Configuration" would mean in practice from a programmer's perspective below:
Helps you to setup a fully working application(web app or otherwise) very quickly by providing you intelligent default configurations that you are most likely to be satisfied to start with.
It does so by something called "AutoConfiguration", where capabilities from the Spring ecosystem of products are "auto-magically" enabled in your application by adding certain dependencies to your classpath; adding such dependencies via maven or gradle is super easy.
Most auto-configuration respects your own configuration, and backs off silently if you have provided your own configuration via your own beans.
You would benefit most if you take the java config approach of configuring your Spring application.
Super silky integration of new capabilities in your application by developing your own auto-configuration components (via annotations!).
Tons of auto-configaration components available ranging from Databases(h2, derby etc.), servlet containers(tomact, jetty etc.) to email and websockets are available. It is easy to develop your own. The important thing is that others can use those technology enablements in their own components. Please feel free to contribute.
Helps write very clean code with all the heavy lifting taken care of you, so that you can focus more on your business logic.
Hope you have fun with Spring Boot; its absolutely among the very best of frameworks to have hit the market in the last decade or so.
It follows opinionated default configuration so it reduces the developer efforts. Spring boot always uses sensible opinions, mostly based on the class path contents. So it overrides the default configuration.

Guice vs 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 5 years ago.
Improve this question
Someone said to me Guice is a better choice for a restful micro-services.
I said ...
Spring Boot offers:
- Core Spring Support - DI + AOP
- Auto-Configuration: Web, Rest, Data, etc
- Activation Profiles: activate bits of code based on profiles
- Simplified Web Development: code driven, no xml, no web.xml etc
- Web Testing Support: successful testing is easy testing
- Security Support: out of the box that can be customized
- JMS: out of the box support and can be excluded if not needed
- Actuator: health, trace, beans, info + much more etc
- Executable and deployable WARs
- Natural fit for restful micro-services
- Fast loading
- extensible, native cloud support and much more
In a real web application these are the kind features that are needed during development and after deployment to production.
Guice-rs complain about older versions of Spring and that it’s slow to load and programmer error issues and so on and so forth.
From my readings Guice was created for super large applications that have many many developers working on them and in this case using something like Spring may take longer to load. Guice is a DI framework that gives you fine-grained control on how to load application code fast.
Now I haven’t used Guice and don’t know Guice yet, can someone form the Guice camp educate me on if/how can Guice provide the above features.
Many thanks!
Spring Context is the package that offers "Core Spring Support - DI + AOP" which you mentioned before. The other features in that list are provided by other spring packages. Spring boot wraps them all into a single bundle with auto-configuration.
TL;DR spring-context is similar to guice, guice by itself does not cover the other items on your list.

Difference between Spring and Spring Boot

There are many people who advised me to use Spring Boot instead of Spring to develop REST web services.
I want to know what exactly the difference between the two is?
In short
Spring Boot reduces the need to write a lot of configuration and boilerplate code.
It has an opinionated view on Spring Platform and third-party libraries so you can get started with minimum effort.
Easy to create standalone applications with embedded Tomcat/Jetty/Undertow.
Provides metrics, health checks, and externalized configuration.
You can read more here http://projects.spring.io/spring-boot/
Unfortunately and I mean this out of personal frustration with Spring boot, I have yet to see any real quantified list, where the differences are explicitly outlined.
There is only qualifications such as the rubbish sentence "...opinionated view..." which are bandied about.
What is clear, is that SpringBoot has wrapped up groups of Spring annotations into its own set of annotations, implicitly.
Further obfuscating, and making the need for anyone starting out in SpringBoot to have to commit to memory what a particular SpringBoot annotation represents.
My reply therefore is of no quantifiable benefit to the original question, which is analogous to that of the SpringBoot authors.
Those behind Spring IMO deliberately set-out to obfuscate, which reflects the obtuseness of their JavaDoc and API's (see SpringBatch API's as an example, if you think I am flaming) that makes one wonder the value of their open-source ethos.
My quest for figuring out SpringBoot continues.
Update. 22-08-2022
Read this (https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.auto-configuration) and you will figure out for yourself what "opinionated" means.
There are over 140 Config classes that Springboot can use for this opinionated view, depending on what is on your classpath.
yes, on your classpath.
Finally and bizzarely, the annotation #SpringBootApplication is a configuration annotation as it includes it.
Go figure :=)
Basically, Spring Boot is an opinionated instance of a Spring application.
Spring Boot is a rapid application development platform. It uses various components of Spring, but has additional niceties like the ability to package your application as a runnable jar, which includes an embedded tomcat (or jetty) server. Additionally, Spring Boot contains a LOT of auto-configuration for you (the opinionated part), where it will pick and choose what to create based on what classes/beans are available or missing.
I would echo their sentiment that if you are going to use Spring I can't think of any reasons to do it without Spring Boot.
Spring Boot is opinionated view of Spring Framework projects.Let's analyse it through one program taken from Spring Boot Documentation.
#RestController
#EnableAutoConfiguration
public class Example {
#RequestMapping("/")
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Example.class, args);
}
}
It's a very basic REST API and you need to add Spring-boot-starter-web in your POM.xml for the same. Since you have added starter-web dependency, the annotation
#EnableAutoConfiguration guesses that you want to develop a web application and sets up Spring accordingly.
Spring Boot auto-configuration attempts to automatically configure your Spring application based on the jar dependencies that you have added. For example, if HSQLDB is on your classpath, and you have not manually configured any database connection beans, then Spring Boot auto-configures an in-memory database.
It's opinionated like maven. Maven creates a project structure for you which it thinks is the general pattern of projects like it adds src/main/java folder or resource folder for you.
Spring boot helps in faster development. It has many starter projects that helps you get going quite faster. It also includes many non functional features like: embedded servers, security, metrics, health checks etc. In short, it makes, spring based application development easier with minimally invading code(Less configuration files, less no of annotations).
Reference: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-documentation-about
For developing common Spring applications or starting to learn Spring, I think using Spring Boot would be recommended. It considerably eases the job, is production ready and is rapidly being widely adopted.
Spring Boot is supposedly opinionated, i.e. it heavily advocates a certain style of rapid development, but it is designed well enough to accommodate exceptions to the rule, if you will. In short, it is a convention over configuration methodology that is willing to understand your need to break convention when warranted
For Spring Framework, you need to configure your project using XML configuration or Java configuration.
But for Spring Boot, these are preconfigured according to Spring team's view for rapid development. That is why Spring Boot is said to be an "opinionated view" of Spring Framework. It follows Convention over Configuration design paradigm.
Note: These configurations include view resolvers for MVC, transaction managers, way of locating container managed beans (Spring beans) and many more. And of course you can override any of these preconfigurations according to your need.
Spring Boot supports embedded servlet containers like Tomcat, Jetty or Undertow to create standalone applications, which Spring Framework doesn't.
Spring eliminate boilerplate code.
Spring-boot eliminates boilerplate configurations.
more

Advantage of 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
I have been trying to understand Spring Boot and maybe migrate my project to it. However I do not get the real advantage of it except the embedded Tomcat. Would you kindly explain to me what is the real power of Spring Boot compared to regular Spring?
Quoting from the Spring Boot Page, it has following features:
Create stand-alone Spring applications
Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
Provide opinionated 'starter' POMs to simplify your Maven configuration
Automatically configure Spring whenever possible
Provide production-ready features such as metrics, health checks and externalized configuration
Absolutely no code generation and no requirement for XML configuration
The big advantage is out of the box configuration based on what it finds and server embedded (you can make a jar run it and go to localhost:8080 to see the result) beside that it has metrics, health checks, externalised configuration, etc.
In my opinion is the perfect tool for building cloud microservices.
Bootstrapping with defaults included in the configuration / jar-dependencies, is the real advantage of Spring boot! Get the things done quickly!
Its just another project from Spring framework, where things look simplified, with strong support for Security, Data, Social etc all features you want for your application.
If you prefer annotations over XML configuration like me you might use
#Configuration for configuration,
#ComponentScan for Dependency Injection,
and #EnableAutoConfiguration to tell spring to guess the defaults
and work along.
The #SpringBootApplication annotation is equivalent to using
#Configuration,
#EnableAutoConfiguration,
and #ComponentScan
with their default attributes.
So things further simplified, with a single annotation doing the work of 3.
It's real easy to get something going from nothing, with loads of useful defaults.
Not so easy if you want to migrate some existing project which will most likely have developed a lot of quirks that are going to be difficult to migrate.
Advantages of SpringBoot:
No need of creating boilerplate configuration
Plenty of SpringBoot Starter to quickly get up and running
DevTools to autorestart server on code/config updates
Embedded Tomcat/Jetty/Undertow support
Easier customization of application properties
Easy management of profile specific properties
Easier dependency management using platform-bom
Here are few of my articles on what are the advantages of SpringBoot and how SpringBoot works.
Why SpringBoot?
How SpringBoot AutoConfiguration magic works?
Biggest of all is that spring boot is aligned with the concept of microservices and can be run from a container anywhere e.g. cloud. This possible because the following nature of springboot
small footprint
standalone services
easier to launch from a container, each service can be in its own container (like docker)
easy to configure and deploy completely from a script. Good for auto-scaling and deploying in the cloud.
In active development,spring boot has the advantage of leave the complex xml file configure.
1.Embedded tomcat discard the web.xml configuration;
2.spring-boot security discard the applicationcontext-security.xml configuration;
3.spring-boot webservice discard the applicationcontext-ws.xml configuration;
4.spring-boot mvc discard the applicationcontext.xml configuration;
5.spring-boot datasource(both Relational Database and nosql Database) discard the applicationcontext.xml configuration,even if more than one datasource.
Discard this configuration file easy our development and improve the efficiency.

Resources