What is the meaning of "boot" in "Spring-Boot" title - java

I know and understand, And have read a lot about
Spring-Boot
, and how it's improving the use of Spring framework.
But I'm still not sure what's the actual meaning of
"Boot"
in the context of this title.
It's mean that it's kick off Spring to more high place, or it gives you boots to walk with Spring? Or something else.
Didn't found any explanation about that.
I will be glad for an answer.
(the source of the name
"Spring"
is also interesting )

Spring is a Framework of Java. Spring-Boot combined means Bootstrapping a Spring Application.
It simply means You have to configure your application to the bare minimum to get your Application up and Running.
Spring boot takes an 'Opinionated' view of what a basic Application should have.
Spring boot bootstraps your Application in such a way that it contains almost everything needed to run a full application.
Basically, Spring-Boot is a way to make a Spring Application up and running without a lot of configuration and boiler-plate code.

Related

Java Spring Boot Hibernate, JPA, MVC, REST confusion

I'm learning Java SE and Spring Boot for a half year now, and watched different courses, and they teaching different ways, and I'm just confused which one does what?
In one course, we're using Eclipse, Spring MVC and Hibernate with MySQL, and writing everything like Servlet, Hibernate configure file, factory, session, and it's just a bit complicated how to do a query for example. In the other course, we're using Spring Initializr, Maven, REST API with PostgreSQL, and it's so much easier, we implementing CRUD repository, and just one line, we can do the query.
And I'm lost at this point. These what I just mention, what exactly we use them for? Why we don't use the simple way in the first course? What we done in the second that I don't have to create a factory and a session to do a simple query?
Is there any post, video or anything about this, for me to understand it?
There are always different ways to solve the same problem. Spring Boot offers you a lot of features to simplify your development. But you don't have to use them. You can always try to implement stuff by yourself. But most of the time, the built in features like the CRUD repository are sufficient to solve your problem.
I can't tell you the exact reasons, why the author of the first course did it this way. Maybe he or she wanted to show the principles, that are hidden beneath the features. Maybe it is just an older course or it is for Spring and not Spring Boot. Spring Boot simplified the setup for Spring and made many advancements.
Spring Framework has been there for a really long time, the ways you have seen are both valid ways, and as far as I understood by your statements is, one way is working with Spring MVC and the second is working with spring boot and spring boot makes things really easy.
You need to understand the difference between the spring MVC framework and spring-boot.
In spring MVC Framework we manage things with configuration files, like XML files and we also fire queries by opening a session first, and then only we can query. But in Spring-boot these things happens behind the scene and that is why it becomes so easy to work with spring-boot but anyhow we still need to understand all this stuff to be able to work properly with this framework.
Spring MVC is a complete HTTP-oriented MVC framework managed by the Spring Framework and based in Servlets. It would be equivalent to JSF in the JavaEE stack. The most popular elements in it are classes annotated with #Controller, where you implement methods you can access using different HTTP requests. It has an equivalent #RestController to implement REST-based APIs.
Spring boot is a utility for setting up applications quickly, offering an out-of-the-box configuration in order to build Spring-powered applications. As you may know, Spring integrates a wide range of different modules under its umbrella, as spring-core, spring-data, spring-web (which includes Spring MVC, by the way), and so on. With this tool, you can tell Spring how many of them to use and you'll get a fast setup for them (you are allowed to change it by yourself later on).
Spring boot is just an auto-configuration tool. Spring MVC is a web framework
Spring boot = Spring MVC + Auto Configuration(Don't need to write xml file for configurations) + Server(You can have embedded server).
Java EE, Spring and Springboot are not the same.
Spring is based on Java EE.
Spring boot is an 'extension' of Spring, especially with auto-configuration.
There are multiple frameworks or libraries which comes with its own advantage and disadvantages, however you need to choose the TechStack that suits your particular application's requirements.
So if you need to build a web app you can use Java Servlet ,but you have to handles multiple concerns yourself and it involves lot of configuration , but there are many frameworks like Spring,Struts,etc which makes the take easy
Similar way you can manually manage dependencies or you can use Maven or gradle to handle the dependencies and building process
Similar way if you need to connect to a Database you can directly use JDBC but there ar multiple ORM(Object Relational Mappers) available which will make the task easier like Hibernate, Jooq, etc
Regarding your question there is Spring framework and also SpringBoot , main motto of Springboot is that it prefers "conventions over configuration" meaning you only need to write very little code to get started and it comes with many starter-packs which basically are pretty much preconfigured, so you can build application easily
Different frameworks and libraries comes with its own learning curve but they reduce the time required for configuration and troubleshooting
Read about Spring MVC and Spring-boot framework. What you have mentioned is first is spring mvc and other is spring boot framework. make you understanding with the questions like, what problem spring boot solves ?? that was or is there in spring mvc.
JPA: The Java Persistence API (JPA) is one possible approach to ORM. Via JPA the developer can map, store, update and retrieve data from relational databases to Java objects and vice versa.
Hibernate: Hibernate is an open-source object-relational mapping(ORM) tool for Java. It provides a framework for mapping an object-oriented domain model to a traditional relational database.
MVC: The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller.
JAVA: One of the most widely used programming languages, Java is used as the server-side language for most back-end development projects, including those involving big data and Android development.
Springboot: Spring Boot is an open-source micro-framework. Spring Boot helps developers create applications that just run. Springboot is a JAVA framework.
REST: Representational state transfer (REST) is a software architectural style that defines a set of constraints to be used for creating Web services.

How can I use a Guice module within a Spring (specifically Spring Boot) context?

I have many "legacy" JAVA jars that were written with Guice dependency injection. I would like to use them in a new Spring Boot application but I appear to be having some issues getting this to work. I noticed that there is a project that indicates it is possible to use a Spring Context in a Guice module (https://github.com/spring-projects/spring-guice), but I would like to do the reverse of that.
Should I just drop the attempt and keep using Guice? Spring boot provides some nice features that I would like to use.
In theory this post answers my question, but I am hoping that something has changed or gotten easier in the last 4 years.
Integrate Guice component into Spring application
A wrapper seems feasible, but could lead to other consequences.

Spring without reflection

Is it possible to substitute default Spring Framework's way of creating and managing objects via reflections with other dependency injection tool (that would be faster, because would avoid reflections), while still holding on Spring's rich API?
For example, I would like to have beans created by Dagger 2 or Tiger or Feather that would still be able to interact with Spring Data/Social/MVC.
https://github.com/google/dagger
https://github.com/google/tiger
https://github.com/zsoltherpai/feather
I know that someone is going to say "start worrying about performance when it will become problem" - well, I would say it's about time to start worrying about it right now.
In my option, it would allow Spring to embrace FaaS (Function as a Service). FaaS jvm is going to be shut down after serving it's call, so You either keep it running (like regular server) and pay for literally every millisecond or some calls may be delayed even few seconds (to boot everything up).
I have found two projects, that are trying to use Spring in FaaS environment and are tackling this problem, but in my option it's easier to remove problem (reflections) that try to overcome it with hacks.
https://github.com/markfisher/spring-cloud-function
https://github.com/kennyk65/spring-cloud-serverless
Or, maybe there is another way to solve this problem and efficiently use Spring in FaaS, that I am not aware of?
Related question: Running Spring Boot on Amazon Lambda
I have been trying to use minimal Spring Framework application (like 3-5 classes) and still it takes (sometimes) 5-15 seconds to handle first request (next are handled in 50-100ms), so minimizing isn't really working in this case.
I'm in the same boat, trying to finding a FaaS friendly DI framework for JVM. Since nothing can beat Spring ecosystem on JVM, it would be great if Spring had reflection-less mechanism and compile time DI. I could not find much on that front though.
Micronaut solves the exact same problem and looks interesting. It has an adapter layer for spring annotations. Micronaut is purpose built for faster start-ups using compile time DI.
Of course, this is good for newer applications but not for very large applications with lots of existing spring code-base.
Today, spring-fu could be an option to create spring application reflection-less approach.
According to its documentation:
Spring Fu is an incubator for JaFu (Java DSL) and KoFu (Kotlin DSL) designed to configure Spring Boot explicitly with code in a declarative way with great discoverability thanks to auto-complete. It provides fast startup (40% faster than regular auto-configuration on a minimal Spring MVC app), low memory consumption and is a good fit with GraalVM native thanks to its (almost) reflection-less approach.
Note: spring-fu is not supposed to be used in production.

Spring project without xml

I'm new to Spring.
The goal is to learn Spring, to use Spring as a production application as it is industry standard.
The requirements of the app:
Hibernate, Security, MVC, RESTful, DI, etc.
The other Spring frameworks might be added in future.
I'm reading "Spring in Action. Third Edition." by Craig Walls.
He gave the examples how to use annotations, but anyway .xml is used.
I'm wonder if I can write the application using only java classes to configure all modules in the application.
I found Spring Boot gives ability to develop not using xml files. However I read the article http://steveperkins.com/use-spring-boot-next-project/ and author said Boot is not ready to be used for production applications.
As far as I understood Boot hides all config work from me. Also my concern is that in future java-developers who knows Spring won't be able to deal with Spring Boot and I wouldn't find proper engineers for the project.
Based upon this I have the following questions:
Is it possible to avoid using xml in Spring or better to mix xml files and annotations?
Is it easy for Spring developers to work with Spring Boot?
Am I able to learn Spring using Spring Boot?
Is Spring Boot is mature enough to use it in production?
Is it possible to avoid using xml in Spring or better to mix xml files and annotations?
Yes, it is. Spring now promotes Java configuration, and it's perfectly doable (I'm doing it) and even easy to only use Java to configure your Spring app. Even without using Boot.
Is it east for Spring developers to work with Spring Boot?
Why wouldn't it? It's well documented, and is based on Spring best practices.
Am I able to learn Spring using Spring Boot?
How could I answer that. Try doing it, and you'll see if you're able or not.
Is Spring Boot is mature enough to use it in production?
Yes, it is. The articleyou linked to is one year old. Spring developers have worked a lot on Boot since then. And Spring uses Boot internally to host their own spring.io web application. See https://github.com/spring-io/sagan
JB Nizet answered 3 answers very clearly. Just an addition about production readiness from my side. We are currently using Spring Boot for an application which we intend to move to production. There has not been any issue till now in prototyping and testing phase. It is very convenient and avoids boilerplate and gives production ready, standalone jar file with embedded server. You can also chose to build war file if you prefer.
"Am I able to learn Spring using Spring Boot?"
As you mentioned that you are new to Spring, it would probably be easier for you to pick up Spring Boot quickly.
To get started, if you are interested, following is the link to a webinar by Josh Long which gives you a really good insight of how easy it is to pick up Spring Boot:
https://www.youtube.com/watch?v=eCos5VTtZoI
I don't know much about Spring Boot but I know pretty much about spring.
First of all you can use both annotations and xml configuration file/s in the same project. That is the most common way as far as I know.
There is also JavaConfig configuration option in which you don't use any xml files instead you use ordinary java class with #Configuration annotation. I didn't use and not saw much usage also.
You can make a spring webapp without any xml, although spring security was ugly to configure last time I looked at that. For a webapp you need to implement WebApplicationInitializer, create an application context and register your #Configuration file(s) with the context. Then you register the dispatcher servlet and you're all set!
I was nearly in the same boat four months ago when I started working on my web app & chose Spring as the platform after evaluating many choices. I also started with Spring in Action but got frustrated when the examples provided by the author didn't work (Spring basic MVC app not working). Since I was just starting, I was looking for some very basic but working examples. But unfortunately, most of the examples which came along with Spring text books, didn't work straight out of the box.
I would like to suggest few Spring resources which I found useful for starters:
http://springbyexample.org/
http://www.petrikainulainen.net/tutorials/
http://www.mkyong.com/tutorials/spring-tutorials/
Pro Spring 4th Edition
Spring Documentation (must read, but take your time to understand the concepts)
Now, to answer your questions, although a bit differently:
Is it possible to avoid using xml in Spring or better to mix xml files and annotations
Now a days, you would find Annotations a lot in Spring code available on net/SO along with XML configuration. However, you can certainly avoid XML if you wish.
Is it easy for Spring developers to work with Spring Boot?
Am I able to learn Spring using Spring Boot?
Is Spring Boot is mature enough to use it in production?
My personal opinion would be to go with Spring Boot only if you believe it offers you certain advantages which are not possible to achieve otherwise. Remember, you may save time now but later on, it would be an additional dependency in your app and you may need to understand its architecture to debug it if things go wrong OR to enhance it as per your app requirements. Better to have minimal dependencies, my learning till now :)

migrating a whole application from simple Java to Spring MVC

I have one simple application running on simple Java code.
There is one server which takes data from client and just prints it back.
Now i want to move this application to Spring MVC so that my server will be running 24*7 and any client can be instantiated from web.
So what are the changes i will need to do ??
if required can explain in detail and also post code.
Start by getting the Spring Tool Suite and use that for your IDE. It's been a great help, since it comes with project templates, like MVC, that you can basically just plug your existing code into (assuming your code is already written in a way that can be used by other applications).
Once you have a basic MVC project, you can slowly add in your own code.
For more complete examples of Spring MVC form applications, the Spring Security project has a number of good samples. The important parts for you will be the methods inside the controllers that deal with form input, and you can ignore the security stuff for your application.

Categories