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
367
votes
10 answers

Using env variable in Spring Boot's application.properties

We are working on a Spring Boot web application, and the database we are using is MySQL; the setup we have is we first test it locally (means we need to install MySQL on our PC); then we push to Bitbucket; Jenkins automatically detects the new…
S M
  • 3,699
  • 3
  • 10
  • 5
367
votes
9 answers

What is the difference between putting a property on application.yml or bootstrap.yml in spring boot?

What is the difference between putting a property on application.yml or bootstrap.yml in spring boot? In logging.config case, the application works differently.
Rys
  • 4,934
  • 8
  • 21
  • 37
350
votes
3 answers

Understanding Spring @Autowired usage

I am reading the spring 3.0.x reference documentation to understand Spring Autowired annotation: 3.9.2 @Autowired and @Inject I am not able to understand the below examples. Do we need to do something in the XML for it to work? EXAMPLE 1 public…
NewQueries
  • 4,841
  • 11
  • 33
  • 39
334
votes
6 answers

What's the difference between Hibernate and Spring Data JPA

What are the main differences between Hibernate and Spring Data JPA? When should we not use Hibernate or Spring Data JPA? Also, when may Spring JDBC template perform better than Hibernate and Spring Data JPA?
hard coder
  • 5,449
  • 6
  • 36
  • 61
327
votes
48 answers

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

I am working on a Spring Boot Batch example with MongoDB and I have already started the mongod server. When I launch my application, I am getting the error below. Any pointers for this issue? *************************** APPLICATION FAILED TO…
Jeff Cook
  • 7,956
  • 36
  • 115
  • 186
327
votes
10 answers

Spring Boot configure and use two data sources

How can I configure and use two data sources? For example, here is what I have for the first data source: application.properties #first db spring.datasource.url = [url] spring.datasource.username = [username] spring.datasource.password =…
juventus
  • 3,282
  • 3
  • 11
  • 7
327
votes
10 answers

Type safety: Unchecked cast

In my spring application context file, I have something like:
Sajal Dutta
  • 18,272
  • 11
  • 52
  • 74
322
votes
4 answers

Difference between Role and GrantedAuthority in Spring Security

There are concepts and implementations in Spring Security, such as the GrantedAuthority interface to get an authority to authorize/control an access. I would like that to permissible operations, such as createSubUsers, or deleteAccounts, which I…
Chinmay
  • 4,726
  • 6
  • 29
  • 36
320
votes
10 answers

Spring @Autowire on Properties vs Constructor

So since I've been using Spring, if I were to write a service that had dependencies I would do the following: @Component public class SomeService { @Autowired private SomeOtherService someOtherService; } I have now run across code that uses…
GSUgambit
  • 4,459
  • 6
  • 25
  • 31
319
votes
17 answers

Reading a List from properties file and load with Spring annotation @Value

I want to have a list of values in a .properties file, i.e.: my.list.of.strings=ABC,CDE,EFG And to load it in my class directly, i.e.: @Value("${my.list.of.strings}") private List myList; As I understand, an alternative of doing this is to…
JackDev
  • 11,003
  • 12
  • 51
  • 68
312
votes
14 answers

Why is Spring's ApplicationContext.getBean considered bad?

I asked a general Spring question: Auto-cast Spring Beans and had multiple people respond that calling Spring's ApplicationContext.getBean() should be avoided as much as possible. Why is that? How else should I gain access to the beans I…
Vinnie
  • 12,400
  • 15
  • 59
  • 80
310
votes
34 answers

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

I included these in the Build Path: all Spring libs Apache Tomcat 7.0 library The project still fails during startup: SEVERE: Error configuring application listener of class…
emeraldhieu
  • 9,380
  • 19
  • 81
  • 139
308
votes
16 answers

Setting active profile and config location from command line in Spring Boot

I have a Spring Boot application. I have three profiles in my application-> development, staging and production. So I have 3 files application-development.yml application-staging.yml application-production.yml My application.yml resides inside…
Vinod Mohanan
  • 3,729
  • 2
  • 17
  • 25
307
votes
19 answers

How can I inject a property value into a Spring Bean which was configured using annotations?

I have a bunch of Spring beans which are picked up from the classpath via annotations, e.g. @Repository("personDao") public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao { // Implementation omitted } In the Spring XML file,…
Dónal
  • 185,044
  • 174
  • 569
  • 824
304
votes
17 answers

When using Spring Security, what is the proper way to obtain current username (i.e. SecurityContext) information in a bean?

I have a Spring MVC web app which uses Spring Security. I want to know the username of the currently logged in user. I'm using the code snippet given below . Is this the accepted way? I don't like having a call to a static method inside this…
Scott Bale
  • 10,649
  • 5
  • 33
  • 36