r/javahelp • • Jun 29 '22

What is Spring actually?

Hey everyone,

I once asked where to find good ressources for Spring development and came through an answer that has said that Spring is not for designing a website but for dynamically getting data onto said website. So I wanted to know what is Spring actually and hope that someone could explain it in an easy way.

Thanks in advance.

20 Upvotes

23 comments sorted by

•

u/AutoModerator Jun 29 '22

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

16

u/No_Ad2641 Jun 29 '22

The spring framework is quite large, but also quite modularized. It's an application framework and inversion of control container to build Java EE style apps, not necessarily only for web.

0

u/codechimpin Jun 29 '22

Came here to say this, but you beat me to it.

7

u/notdeadpool Jun 29 '22

Spring has lots of components and things you can use it for. I have used it for making rest APIs - this is where you are making methods that can retrieve requests and can send back responses. E.g. Request for a list of item names, sends back item names as JSON. The spring.io website has some really useful easy tutorials on it.

7

u/Roachmeister Java Dev Jun 29 '22

Spring has nothing to do with web applications. When people say that, they are probably confusing it with Spring Boot, which is a subset of Spring. At my job, 90% of our code is built on Spring, and 0% of it is web apps.

Spring is a Dependency Injection framework, also referred to as an Inversion of Control framework. It allows you to separate the configuration, or "plumbing" of your application from the business logic.

3

u/No_Ad2641 Jun 29 '22

I would not say "nothing to do with web". A significant portion of the whole spring ecosystem is about web, but I agree that there is major use cases where web-stuff is out of the picture as well. I.e. Spring-batch and spring-data. Guess it depends on how you define a web application too.

1

u/Roachmeister Java Dev Jun 29 '22

Or just plain Spring. We just use it as a way to wire our applications up with Beans. No Spring batch or Spring data, just Spring.

1

u/No_Ad2641 Jun 30 '22

Theres no "just spring", spring-core then, including spring-beans that provide the DI part of it.

1

u/Roachmeister Java Dev Jun 30 '22

Yes, when I say "just Spring" I mean essentially the 4 Jar files spring-core, spring-beans, spring-context, and spring-test (for unit testing). Those provide the core DI functionality of Spring. There are of course many other libraries that add additional capabilities, but they all depend on those.

2

u/nutrecht Lead Software Engineer / EU / 20+ YXP Jun 30 '22

When people say that, they are probably confusing it with Spring Boot, which is a subset of Spring.

Spring Boot doesn't have anything 'more' or 'less' to do with webapplications. It's just preconfiguired starters for Spring with sensible defaults that save you from doing a lot of boilerplate. That's all.

And Spring is also used a lot in the back-ends of web applications. Sometimes it serves HTML directly. Sometimes it just serves APIs. Sometimes it does other stuff.

Spring is a Dependency Injection framework

Spring is MUCH more than that. It's basically a collection of libraries that all work together. Spring Core does DI, but also a lot more than just DI.

7

u/nothingexceptfor Jun 29 '22

a season, usually around April in the northern hemisphere

1

u/djavaman Jun 29 '22

Shirley you must be joking.

6

u/zipn7 Jun 29 '22

A dependency injection frameworkish?

1

u/Orffyreus Jun 29 '22

Spring (and especially Spring Boot) mostly is about helping you to focus on domain implementations. It is comparable to Jakarta EE (the "official" stable specifications) in that case and additionally it has de facto standard implementations for more specific technical stuff (they test and define a lot of library versions that play together nicely, just take a look at their Maven bill of materials where all the compatible library versions are defined: https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.7.1/spring-boot-dependencies-2.7.1.pom). All the technical stuff can be separated in a service layer (if you wish) and you can focus on implementing the domain requirements (inside a separate and independent layer that is called by the service layer, if you wish).

1

u/wsppan Jun 29 '22

Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform.

A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

1

u/throwaway_clean1 Jun 29 '22

Spring is an organization (now owned by VMWare, formerly owned by Pivotal) that maintains lots of different jars/libraries. For example, there's Spring Boot, which is a library that makes it easy to start a web server. There's also Spring Data which makes it easy to connect to different databases.

The most popular libraries are Spring Boot, which I mentioned above, and the Spring Framework, which makes it easy to start an application with different objects for different environments (e.g. you make a blueprint for objects that are used in a testing environment, and a separate one with objects for the prod environment).

2

u/nutrecht Lead Software Engineer / EU / 20+ YXP Jun 30 '22

For example, there's Spring Boot, which is a library that makes it easy to start a web server.

That's not what Spring Boot is. Spring Boot is just a collection of starters to make it easier / faster to use Spring in applications. That's all.

1

u/throwaway_clean1 Jul 05 '22

That's how it's marketed. If you want to confuse people, don't go to an educational subreddit

1

u/stevesobol Jun 30 '22

now owned by VMWare

About to be acquired by Broadcom.

-2

u/msx Jun 29 '22

An overengineered mess.

3

u/jcarlo1 Jun 29 '22

for a beginner like me, it really is a mess for my perspective XD

3

u/thenivekproject Jun 29 '22

Pls allow me to introduce you to Spring Batch. Lol

2

u/tacticalnudge Jun 29 '22

You must be new to Java.

All kidding aside, it has its merits. For all it's overengineering, it has wide adoption, so you will seldom get completely stuck or end up developing an exorbitant amount of specialisation in a very niche framework that exactly one company in the known universe uses.

It also has its moments- it tries to hide a lot of the boilerplating from you while still allowing you to provide your own implementation if you want to deviate from the rails.

I have seen far too many Spring-ish projects that insisted on doing things the wrong way, so I can understand the mess aspect.

Of course, the beauty of software development is that you can write your own framework with hookers and blackjack that does things exactly the way you want without the overengineering, but then you might end up finding yourself with a very niche framework that exactly one company in the known universe uses.