Skip to main content

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. For Spring Boot related questions, also include the tag [spring-boot].

781 votes
22 answers
759k views

Why is my Spring @Autowired field null?

Note: This is intended to be a canonical answer for a common problem. I have a Spring @Service class (MileageFeeCalculator) that has an @Autowired field (rateService), but the field is null when I try ...
chrylis -cautiouslyoptimistic-'s user avatar
110 votes
14 answers
109k views

Why does Spring MVC respond with a 404 and report "No mapping found for HTTP request with URI [...] in DispatcherServlet"?

I'm writing a Spring MVC application deployed on Tomcat. See the following minimal, complete, and verifiable example public class Application extends ...
Sotirios Delimanolis's user avatar
52 votes
4 answers
41k views

Spring JSF integration: how to manage a bean and inject a Spring component/service?

I understand that a managed bean works like a controller, because your only task is "link" the View Layer with Model. To use a bean as a managed bean I must declare @ManagedBeanannotation, doing ...
Ronaldo Lanhellas's user avatar
75 votes
1 answer
154k views

What is a NoSuchBeanDefinitionException and how do I fix it?

Please explain the following about NoSuchBeanDefinitionException exception in Spring: What does it mean? Under what conditions will it be thrown? How can I prevent it? This post is designed to be a ...
Sotirios Delimanolis's user avatar
210 votes
11 answers
151k views

Spring @Transaction method call by the method within the same class, does not work?

I am new to Spring Transaction. Something that I found really odd, probably I did understand this properly. I wanted to have a transactional around method level and I have a caller method within the ...
Mike's user avatar
  • 2,111
2593 votes
30 answers
1.2m views

What's the difference between @Component, @Repository & @Service annotations in Spring?

Can @Component, @Repository, and @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device? In other words, if I have a ...
Colin McCree's user avatar
458 votes
16 answers
610k views

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 a freemarker and a PDF generation ...
MilindaD's user avatar
  • 7,643
342 votes
10 answers
570k views

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 = [...
juventus's user avatar
  • 3,432
27 votes
11 answers
76k views

CORS issue - No 'Access-Control-Allow-Origin' header is present on the requested resource

I have created two web applications - client and service apps.The interaction between client and service apps goes fine when they are deployed in same Tomcat instance. But when the apps are deployed ...
JavaDeveloper's user avatar
390 votes
6 answers
181k views

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, ...
user448070's user avatar
  • 4,035
38 votes
7 answers
25k views

What causes "java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute"?

This is meant to be an extensive canonical question & answer post for these types of questions. I'm trying to write a Spring MVC web application where users can add movie names to an in-memory ...
Sotirios Delimanolis's user avatar
49 votes
2 answers
12k views

When is it necessary or convenient to use Spring or EJB3 or all of them together?

I'm a little confused by the mixed use of JSF2+Spring+EJB3 or any combination of those. I know one of the Spring principal characteristics is dependency injection, but with JSF managed beans I can use ...
user2018726's user avatar
136 votes
25 answers
481k views

How to configure CORS in a Spring Boot + Spring Security application?

I use Spring Boot with Spring Security and Cors Support. If I execute following code url = 'http://localhost:5000/api/token' xmlhttp = new XMLHttpRequest xmlhttp.onreadystatechange = -> if ...
RSX's user avatar
  • 2,419
352 votes
3 answers
469k views

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 ...
NewQueries's user avatar
  • 4,901
54 votes
4 answers
91k views

Dynamic spring data jpa repository query with arbitrary AND clauses

I'm using Spring data jpa repositories, Got a requirement to give search feature with different fields. Entering fields before search is optional.I have 5 fields say EmployeeNumber, Name, Married,...
Mr.Chowdary's user avatar
  • 3,399

15 30 50 per page
1
2 3 4 5
1462