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
5
votes
2 answers

Intellij idea: JPA annotations in property instead of getter

Is there a way to make IntelliJ put the auto generated JPA Entity annotations (@Column, @Id, etc) in the properties themselves, instead of the getter? There's an answer that points to a Hub issue that works for xml-based configurations, but there…
llappall
  • 2,852
  • 3
  • 23
  • 26
5
votes
2 answers

Spring annotation value from configuration

In my Spring Boot application I have configured following JMS Listener: @Component public class Consumer { @JmsListener(destination = "image.index.queue") public void receiveQueue(IndexRequest indexRequest) { ... } } How…
alexanoid
  • 24,051
  • 54
  • 210
  • 410
5
votes
3 answers

Backslash (\) in .proprties file is being ignored by Spring's 'Environment' variable

I am trying to load a config.proprties file data in a Spring @Configuration java class using @PropertySource and Environment variable. Example:…
Sanjeev
  • 425
  • 10
  • 17
5
votes
2 answers

How to do a @CustomAnnotation annotation that triggers a filter in Spring 3 MVC?

I'd like to do @CustomFilter annotation in Spring 3 mvc like this: @CustomFilter @RequestMapping("/{id}") public Account retrieve(@PathVariable Long id) { // ... } (Assuming upgrading to Spring 4 is constrained) What I have to do at the moment…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
5
votes
1 answer

change datasource url at runtime in spring

I have spring application configured via annotations. Here is part of my config @Configuration @EnableTransactionManagement public class JpaSpringConfiguration { @Bean(destroyMethod = "close") @Lazy @Primary public BasicDataSource…
Martin Barnas
  • 185
  • 1
  • 13
5
votes
2 answers

Purpose of using permitAll() in PreAuthorize annotation in Spring Security

Being new to spring security framework, I wanted to know why do we use @PreAuthorize("permitAll()") with methods ? The documentation says that permitAll always evaluates to true.…
Zack
  • 2,078
  • 10
  • 33
  • 58
5
votes
1 answer

How to autowire Service with-in JUnit Tests

How to autowire Service in test class by only using spring-annotations when I try I got this error below , whereas @Service annotation used in UserServiceImp class 2014-12-20 15:35:52 ERROR TestContextManager:334 - Caught exception while…
5
votes
1 answer

SpringMVC @PathVariable is truncated

I am using SpringMVC 3.1.3. @PathVariable is truncated/trimmed if it has whitespaces in the end. Is there a way so prevent the trimming @RequestMapping(value="deleteConfig/{id}/", method=RequestMethod.DELETE) public @ResponseBody JsonResponse
dogfish
  • 2,646
  • 4
  • 21
  • 37
5
votes
3 answers

Specify order to Spring @Autowired

I am using Spring Framework 4. I have a class (say ClassA) in which another class (say ClassB) is been used. ClassA's member variables are getting value from ClassB. ClassB has a static method which read data from properties file. In ClassB a static…
Parth Bhagat
  • 509
  • 1
  • 11
  • 24
5
votes
2 answers

@EnableAspectJAutoProxy not work with proxyTargetClass=false

I am learning about Spring AOP at first time. I am reading about in this sites: Site2 and Site1 Following this I have made the next classes Main class: public class App { public static void main(String[] args) { …
Dani
  • 4,001
  • 7
  • 36
  • 60
5
votes
1 answer

How can I specify an instance-specific @Value in a @Scope("prototype") bean using annotations?

I have a bean that contains two autowired instances of the same component: @Component public SomeBean { @Autowired private SomeOtherBean someOtherBean1; @Autowired private SomeOtherBean someOtherBean2; ... } SomeOtherBean has a…
Ben Turner
  • 131
  • 6
5
votes
1 answer

How to include jsp pages using Spring form tag?

I'm using Spring, in that I have user.jsp user.jsp has three separate divisons: 1. Personal, 2. Educational, 3. Awards. Each section has different forms .jsp that I have created. Now I'm thinking to include these three forms into user.jsp and…
Java Developer
  • 1,873
  • 8
  • 32
  • 63
5
votes
4 answers

AOP using AspectJ not working in spring?

My Aspect class will be , @Configuration @EnableAspectJAutoProxy @Component @Aspect public class AspectClass { @Before("execution(* com.pointel.aop.test1.AopTest.beforeAspect())") public void logBefore(JoinPoint joinPoint) { …
Human Being
  • 8,269
  • 28
  • 93
  • 136
5
votes
1 answer

What is the correct annotation configuration for Spring data and neo4j

I'm trying to configure Spring-data with Neo4j with an @configuration class but I cannot find any reference material on how to do that properly and I'm running into one issue after the next. Here's what I've pieced together so far: package…
chrisjleu
  • 4,329
  • 7
  • 42
  • 55
5
votes
1 answer

Some information about @MatrixVariable annotation ins Spring 3.2

today I am studying the Spring MVC showcase dowlodable from the STS dashboard I have some doubt about the new annotation @MatrixVariable introduced by Spring 3.2 version and the use of the Matrix variables in the URI path. Within my home.jsp view I…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596