Questions tagged [spring-annotations]

A common placeholder for issues related to the use of annotations with the Spring framework

The Spring Framework () provides several annotation-driven configuration options from wiring beans to managing transaction.

Annotation types

JSR support

  • JSR 107
    • @CacheResult
    • @CachePut
    • @CacheRemove
    • @CacheRemoveAll
    • @CacheDefaults
    • @CacheKey
    • @CacheValue
  • JSR 250:
    • @Resource
  • JSR 303:
    • @Valid
    • @NotNull
    • @Size, etc
  • JSR 330:
    • @Inject
    • @Named

Useful links

1301 questions
4
votes
1 answer

Spring: @Value vs. @Autowired

I'm having some issues with injection in the application I'm working on (using Spring Version 3.1.2). To start with, I'm seeing a lot of code like this: @Value("#{searchRequestBean}") private SearchRequest…
Jeff Levine
  • 2,083
  • 9
  • 30
  • 38
4
votes
2 answers

When should we use @PreAuthorize and @Secured

I read this stackoverflow post What's the difference between @Secured and @PreAuthorize in spring security 3? However,I am still not clear as to what is the big difference between the two in terms of security? In what scenarios should we go for…
Zack
  • 2,078
  • 10
  • 33
  • 58
4
votes
1 answer

Spring Annotation based Controllers and Duplicate Form Submission

How does one disable duplicate form submission on Annotation based controllers.
Eqbal
  • 4,722
  • 12
  • 38
  • 47
4
votes
4 answers

No mapping found for HTTP request with URI [/WEB-INF/pages/MainPage.jsp] in DispatcherServlet with name 'dispatcherServlet'

I am trying to configure Spring Boot using annotations. I have class @EnableWebMvc @Configuration @ComponentScan({ ... }) @EnableTransactionManagement @EnableAutoConfiguration @Import({ SecurityConfig.class }) public class AppConfig extends…
Toro Boro
  • 377
  • 5
  • 16
4
votes
2 answers

How it work the Spring @Autowired annotation on a constructor?

I am studying Spring framework and I have the following doubt related the @Autowired annotation on the constructor of this example: @Component public class TransferServiceImpl implements TransferService { @Autowired public…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
4
votes
2 answers

Spring Aggregator Annotation doesnot have expireGroupUponCompletion and persistenceStore as input

I recently moved to Spring boot and started converting all the XMLs to Java Configs. The @Aggregate annotation does not have expireGroupUponCompletion and persistenceStore as the input. Is there any other way we can specify these things?
Nikhil
  • 83
  • 6
4
votes
1 answer

Url getting modified after request is received at the server

I am trying to develop a RESTful web service using Spring framework with Apache Tomcat. I added two controller classes which had some 5-6 endpoints which were working fine. But since yesterday when I am trying add another endpoint I am getting a…
araju
  • 103
  • 1
  • 5
4
votes
1 answer

set resource in spring configuration file

i am trying to config dozer in spring configuration. when using xml config it would be like how can i…
alizelzele
  • 892
  • 2
  • 19
  • 34
4
votes
1 answer

How to set annotation property/attribute programmatically?

So I need to set the timeout parameter for @Transactional annotation. This property will come from a property file which I'm not able to do since I'm encountering "The value for annotation attribute Transactional.timeout must be a constant…
learning_dev_me
  • 269
  • 2
  • 3
  • 9
4
votes
2 answers

Spring @Async cancel and start?

I have a spring MVC app where a user can kick off a Report generation via button click. This process could take few minutes ~ 10-20 mins. I use springs @Async annotation around the service call so that report generation happens asynchronously. While…
bond
  • 11,236
  • 7
  • 48
  • 62
4
votes
1 answer

creating custom annotation in spring mvc and getting httpservletrequest object

I want to create custom annotation and put that annotation on method level using HttpServletRequest object. so far I did this: Created…
user1918096
  • 153
  • 1
  • 3
  • 10
4
votes
1 answer

Injecting property values from property file or xml file into PreAuthorize(...) java annotation (Unresolved)

I've asked this question in my previous post here: SpEL for spring security: Passing Values from XML to Java based SpEL configuration. But it wasn't yet resolved. I want to inject values either from an xml configuration or from external file into…
user262
  • 198
  • 1
  • 3
  • 13
4
votes
3 answers

Caching in Spring on methods with array parameters

I have a service with multiple methods and am attempting to cache them using Spring @Cacheable annotations. Everything works fine except I've found the methods with an array as a method parameter are not cached. This somewhat makes sense considering…
acvcu
  • 2,476
  • 10
  • 40
  • 56
4
votes
4 answers

Get bean of @Service annotated class?

In my web application, I am not using applicationContext.xml. How can I get the bean of @Service annotated class? If I used the applicationContext.xml in my web application, I have to load the applicationContext.xml every time to get the bean of the…
Human Being
  • 8,269
  • 28
  • 93
  • 136
4
votes
2 answers

Handling multiple validation annotations error messages

I am trying out Validations in SpringMVC using annotations... I used 2 annotations for a field to validate @NotEmpty(message="required") @Size(min="3" max="8" message="Out of range") private String password; The issue i'm facing is, when the field…