Questions tagged [spring-4]

Version 4.x of the Spring Framework

Use for general Spring related questions. This tag is for questions that are specific to versions 4.x only.

618 questions
225
votes
7 answers

Difference between the annotations @GetMapping and @RequestMapping(method = RequestMethod.GET)

What's the difference between @GetMapping and @RequestMapping(method = RequestMethod.GET)? I've seen in some Spring Reactive examples, that @GetMapping was used instead of @RequestMapping
nowszy94
  • 3,151
  • 4
  • 18
  • 33
219
votes
4 answers

When use ResponseEntity and @RestController for Spring RESTful applications

I am working with Spring Framework 4.0.7, together with MVC and Rest I can work in peace with: @Controller ResponseEntity For example: @Controller @RequestMapping("/person") @Profile("responseentity") public class…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
79
votes
8 answers

Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]

I'm trying to handle MethodArgumentNotValidException using @ControllerAdvice as code given below: @ControllerAdvice public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { private Logger log =…
Krishna
  • 1,865
  • 4
  • 18
  • 26
61
votes
8 answers

How to return JSON data from spring Controller using @ResponseBody

Spring version 4.2.0, Hibernate 4.1.4 Here is my Controller function: @RequestMapping(value = "/mobile/getcomp", method = RequestMethod.GET) @ResponseBody public List listforCompanies() { List listOfCompanies= new…
Zahid Khan
  • 1,250
  • 3
  • 15
  • 31
56
votes
2 answers

When use AbstractAnnotationConfigDispatcherServletInitializer and WebApplicationInitializer?

I am working with Spring 4.0.7 I did a research about configure Spring MVC through JavaConfig. Practically until yesterday I have seen two configurations using these two options extends AbstractAnnotationConfigDispatcherServletInitializer extends…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
51
votes
2 answers

Difference between @EntityScan and @ComponentScan

I am trying to understand the difference here. I see that a class has been annotated with both of them with same package example : @Configuration @EntityScan("some.known.persistence") @ComponentScan({ "some.known.persistence"}) public class…
Raghuveer
  • 2,859
  • 7
  • 34
  • 66
42
votes
2 answers

AbstractMethodError on deploying Spring 4.0 in Tomcat 6

I am getting below exception on deploying Spring 4.0.1 app in Tomcat 6.0.37: SEVERE: Exception sending context initialized event to listener instance of class…
Vikas Sharma
  • 1,235
  • 2
  • 27
  • 53
41
votes
1 answer

WebSocket with Sockjs & Spring 4 but without Stomp

Is there a way to use WebSockets with SockJS client and Spring 4 server but not using STOMP? Based on this tutorial from Spring's website, I know how to set up a WebSocket based application using Stomp and Spring 4. On the client side, we have: …
BlueChips23
  • 1,861
  • 5
  • 34
  • 53
41
votes
3 answers

Multiple scenarios @RequestMapping produces JSON/XML together with Accept or ResponseEntity

I am working with Spring 4.0.7 About Spring MVC, for research purposes, I have the following: @RequestMapping(value="/getjsonperson", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
40
votes
2 answers

How to use JasperReports with Spring MVC?

I've been investigating the use of JasperReports (6.0.0) with Spring MVC (4.1.3) to generate PDF reports. Spring is rife with "Spring specific" ways to integrate with JasperReports to generate PDFs: Use JasperReportsPdfView relies on now deprecated…
Brice Roncace
  • 10,110
  • 9
  • 60
  • 69
36
votes
1 answer

Relation between WebSecurityConfigurerAdapter and ResourceServerConfigurerAdapter

I'm trying to integrate Spring OAuth2 into Spring MVC REST. Most of the Spring OAuth2 examples, there is only ResourceServerConfigurerAdapter and some of have WebSecurityConfigurerAdapter as well. I'm not going to integrate OAuth with Google,…
sura2k
  • 7,365
  • 13
  • 61
  • 80
36
votes
5 answers

Spring 4 - addResourceHandlers not resolving the static resources

My maven spring project directory structure is shown below. I am using Spring-4 annotation based configuration. I configure the resources like below. I tried many ways that are suggested in many Stackoverflow questions and other websites Spring 4…
vvra
  • 2,832
  • 5
  • 38
  • 82
34
votes
1 answer

Spring async method called from another async method

I'm using Spring 4 and I've noticed an odd behaviour... if I'm calling an async method multiple times from a normal instance method then they are all called in different threads and finish at random times. But if I call multiple times an async…
spauny
  • 4,976
  • 9
  • 44
  • 61
32
votes
5 answers

Using @Scheduled and @EnableScheduling but gives NoSuchBeanDefinitionException

I have followed very simple examples online to set up a cron job in Spring yet I keep getting this error in my Tomcat startup log each and every time: 2015-05-25 00:32:58 DEBUG ScheduledAnnotationBeanPostProcessor:191 - Could not find default…
logixplayer
  • 939
  • 2
  • 13
  • 23
32
votes
3 answers

H2 database console spring boot Load denied by X-Frame-Options

I`m building a skeletal project for dev with spring 4 boot security and others. Using H2 while attempting to log into the db console and manage my db i get the following error. The page is blank, with 4 bugs in firebug konsole : Load denied by…
1
2 3
41 42