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
304
votes
23 answers

Injecting Mockito mocks into a Spring bean

I would like to inject a Mockito mock object into a Spring (3+) bean for the purposes of unit testing with JUnit. My bean dependencies are currently injected by using the @Autowired annotation on private member fields. I have considered using…
teabot
  • 15,358
  • 11
  • 64
  • 79
300
votes
7 answers

How to use multiple @RequestMapping annotations in spring?

Is it possible to use multiple @RequestMapping annotations over a method? Like : @RequestMapping("/") @RequestMapping("") @RequestMapping("/welcome") public String welcomeHandler(){ return "welcome"; }
wuntee
  • 12,170
  • 26
  • 77
  • 106
295
votes
22 answers

Spring Boot - Loading Initial Data

I'm wondering what the best way to load initial database data before the application starts? What I'm looking for is something that will fill my H2 database with data. For example, I have a domain model "User" I can access users by going to /users…
Lithicas
  • 3,793
  • 7
  • 23
  • 32
293
votes
6 answers

Spring cron expression for every day 1:01:am

I'm trying to have my code execute on a fixed schedule, based on a Spring cron expression. I would like the code to be executed every day at 1:01:am. I tried the following expression, but this didn't fire up for me. What's wrong with the syntax…
d-man
  • 57,473
  • 85
  • 212
  • 296
291
votes
5 answers

How does spring.jpa.hibernate.ddl-auto property exactly work in Spring?

I was working on my Spring boot app project and noticed that, sometimes there is a connection time out error to my Database on another server(SQL Server). This happens specially when I try to do some script migration with FlyWay but it works after…
METTAIBI
  • 3,201
  • 5
  • 22
  • 29
291
votes
18 answers

How do I activate a Spring Boot profile when running from IntelliJ?

I have 5 environments: - local (my development machine) - dev - qc - uat - live - staging I want different application properties to be used for each environment, so I have the following properties files each which have a different URL for…
dleerob
  • 4,951
  • 4
  • 24
  • 36
279
votes
11 answers

Difference between Spring MVC and Spring Boot

I have just started learning Spring. In my next step, I would like to develop bigger web applications. Now I am wondering if I should start with Spring Boot or Spring MVC. I have already read some stuff, but it is confusing because both look…
Gero
  • 12,993
  • 25
  • 65
  • 106
273
votes
23 answers

Spring - No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call

I get this error when trying to invoke "persist" method to save entity model to database in my Spring MVC web application. Can't really find any post or page in internet that can relate to this particular error. It seems like something's wrong with…
Michał Bil
  • 3,179
  • 5
  • 20
  • 24
272
votes
5 answers

Mockito: Inject real objects into private @Autowired fields

I'm using Mockito's @Mock and @InjectMocks annotations to inject dependencies into private fields which are annotated with Spring's @Autowired: @RunWith(MockitoJUnitRunner.class) public class DemoTest { @Mock private SomeService service; …
user2286693
  • 3,007
  • 2
  • 17
  • 17
272
votes
4 answers

RESTful Authentication via Spring

Problem: We have a Spring MVC-based RESTful API which contains sensitive information. The API should be secured, however sending the user's credentials (user/pass combo) with each request is not desirable. Per REST guidelines (and internal business…
Chris Cashwell
  • 22,308
  • 13
  • 63
  • 94
271
votes
4 answers

What is this spring.jpa.open-in-view=true property in Spring Boot?

I saw spring.jpa.open-in-view=true property in Spring Boot documentation for JPA configuration. Is the true default value for this property if it's not provided at all?; What does this really do? I did not find any good explaining for it; Does it…
Carlos Alberto
  • 7,761
  • 13
  • 52
  • 72
269
votes
6 answers

How to call a method after bean initialization is complete?

I have a use case where I need to call a (non-static) method in the bean only-once at the ApplicationContext load up. Is it ok, if I use MethodInvokingFactoryBean for this? Or we have a some better solution? As a side note, I use…
peakit
  • 28,597
  • 27
  • 63
  • 80
267
votes
22 answers

BeanFactory vs ApplicationContext

I'm pretty new to the Spring Framework, I've been playing around with it and putting a few samples apps together for the purposes of evaluating Spring MVC for use in an upcoming company project. So far I really like what I see in Spring MVC, seems…
matt b
  • 138,234
  • 66
  • 282
  • 345
266
votes
3 answers

Spring CrudRepository findByInventoryIds(List inventoryIdList) - equivalent to IN clause

In Spring CrudRepository, do we have support for "IN clause" for a field? ie something similar to the following? findByInventoryIds(List inventoryIdList) If such support is not available, what elegant options can be considered? Firing…
Espresso
  • 5,378
  • 4
  • 35
  • 66
261
votes
8 answers

Does Spring @Transactional attribute work on a private method?

If I have a @Transactional -annotation on a private method in a Spring bean, does the annotation have any effect? If the @Transactional annotation is on a public method, it works and open a transaction. public class Bean { public void doStuff() { …
Juha Syrjälä
  • 33,425
  • 31
  • 131
  • 183