Questions tagged [spring]

The Spring Framework is an open-source framework for application development on the Java platform. At its core is rich support for component-based architectures, and it currently has over twenty highly integrated modules.

The Spring Framework is an open-source application framework for the Java platform.

Spring is a non-invasive, versatile, robust framework.

Spring framework complements the Java EE APIs but is not a replacement for Java EE. It reduces most boilerplate code, reducing the burden on developers.

Spring provides services and functionalities across the application domain, including a core Inversion of Control container, technology-agnostic data-access and MVC layers, extensive AOP support, task scheduling, and various integration patterns designed to make distributed system development more uncomplicated and more straightforward. While some Spring modules are simple wrappers and helpers over the Java EE specifications, most go far beyond the Java EE specification.

The latest Spring Framework Reference Documentation can be found here.

Spring version history:

Version    Date   
5.2.x    Dec, 2020
5.1.x    Sep, 2018 
5.0.x    Sep, 2017 
4.3.x    Jun, 2016 
4.2.x    Jul, 2015 
4.1.x    Sep, 2014 
4.0.x    Dec, 2013 
3.2.x    Dec, 2012 
3.1.x    Dec, 2011 
3.0.x    Dec, 2009 
2.5.x    Nov, 2007 
2.0.x    Jun, 2006 
1.2.x    Mar, 2005 
1.1.x    Jul, 2004 
1.0.x    Feb, 2004 

Frequently Asked Questions

People often ask about the following Spring topics:

Guides:

Video tutorial on Spring Framework

Examples:

Blog:

Related tags

More information:

Official Logo:


Spring logo

208702 questions
452
votes
15 answers

Downloading a file from spring controllers

I have a requirement where I need to download a PDF from the website. The PDF needs to be generated within the code, which I thought would be a combination of freemarker and a PDF generation framework like iText. Any better way? However, my main…
MilindaD
  • 7,533
  • 9
  • 43
  • 63
451
votes
13 answers

How to respond with an HTTP 400 error in a Spring MVC @ResponseBody method returning String

I'm using Spring MVC for a simple JSON API, with @ResponseBody based approach like the following. (I already have a service layer producing JSON directly.) @RequestMapping(value = "/matches/{matchId}", produces =…
Jonik
  • 80,077
  • 70
  • 264
  • 372
440
votes
6 answers

Spring - @Transactional - What happens in background?

I want to know what actually happens when you annotate a method with @Transactional? Of course, I know that Spring will wrap that method in a Transaction. But, I have the following doubts: I heard that Spring creates a proxy class? Can someone…
peakit
  • 28,597
  • 27
  • 63
  • 80
439
votes
11 answers

@Resource vs @Autowired

Which annotation, @Resource (jsr250) or @Autowired (Spring-specific) should I use in DI? I have successfully used both in the past, @Resource(name="blah") and @Autowired @Qualifier("blah") My instinct is to stick with the @Resource tag since it's…
mlo55
  • 6,663
  • 6
  • 33
  • 26
438
votes
10 answers

Only using @JsonIgnore during serialization, but not deserialization

I have a user object that is sent to and from the server. When I send out the user object, I don't want to send the hashed password to the client. So, I added @JsonIgnore on the password property, but this also blocks it from being deserialized into…
chubbsondubs
  • 37,646
  • 24
  • 106
  • 138
425
votes
9 answers

How to use OrderBy with findAll in Spring Data

I am using spring data and my DAO looks like public interface StudentDAO extends JpaRepository { public findAllOrderByIdAsc(); // I want to use some thing like this } In above code, commented line shows my intent. Can…
Prashant Shilimkar
  • 8,402
  • 13
  • 54
  • 89
425
votes
15 answers

Difference between spring @Controller and @RestController annotation

Difference between spring @Controller and @RestController annotation. Can @Controller annotation be used for both Web MVC and REST applications? If yes, how can we differentiate if it is Web MVC or REST application.
Srikanth
  • 4,349
  • 3
  • 13
  • 8
416
votes
19 answers

Running code after Spring Boot starts

I want to run code after my spring-boot app starts to monitor a directory for changes. I have tried running a new thread but the @Autowired services have not been set at that point. I have been able to find ApplicationPreparedEvent, which fires…
stewsters
  • 4,335
  • 3
  • 15
  • 7
411
votes
8 answers

@RequestParam vs @PathVariable

What is the difference between @RequestParam and @PathVariable while handling special characters? + was accepted by @RequestParam as space. In the case of @PathVariable, + was accepted as +.
user1857181
  • 4,121
  • 3
  • 13
  • 3
396
votes
18 answers

Spring MVC @PathVariable with dot (.) is getting truncated

This is continuation of question Spring MVC @PathVariable getting truncated Spring forum states that it has fixed(3.2 version) as part of ContentNegotiationManager. see the below…
Kanagavelu Sugumar
  • 18,766
  • 20
  • 94
  • 101
388
votes
6 answers

Difference between applicationContext.xml and spring-servlet.xml in Spring Framework

Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework? Will the properties files declared in applicationContext.xml be available to DispatcherServlet? On a related note, why do I need a *-servlet.xml at all? Why is…
user448070
  • 4,023
  • 3
  • 16
  • 11
383
votes
17 answers

Spring RestTemplate GET with parameters

I have to make a REST call that includes custom headers and query parameters. I set my HttpEntity with just the headers (no body), and I use the RestTemplate.exchange() method as follows: HttpHeaders headers = new…
Elwood
  • 4,451
  • 4
  • 18
  • 20
374
votes
13 answers

Populating Spring @Value during Unit Test

I'm trying to write a Unit Test for a simple bean that's used in my program to validate forms. The bean is annotated with @Component and has a class variable that is initialized using @Value("${this.property.value}") private String thisProperty; I…
Kyle
  • 14,036
  • 11
  • 46
  • 61
372
votes
15 answers

How to check String in response body with mockMvc

I have simple integration test @Test public void shouldReturnErrorMessageToAdminWhenCreatingUserWithUsedUserName() throws Exception { mockMvc.perform(post("/api/users").header("Authorization",…
pbaranski
  • 22,778
  • 19
  • 100
  • 117
369
votes
31 answers

Spring Boot - How to log all requests and responses with exceptions in single place?

I'm working on REST API with spring boot. I need to log all requests with input params (with methods, eg. GET, POST, etc.), request path, query string, corresponding class method of this request, also response of this action, both success and…
Teimuraz
  • 8,795
  • 5
  • 35
  • 62