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
0
votes
1 answer

how to store and return image as model attribute in spring 4

I am building a web app for blogging using spring boot and mongodb.I tried gridFS for storing and used input stream for storing data. But I can't return image as a model attribute.It's my controller class @RestController public class HomeController…
0
votes
1 answer

add requestmapping annotation on bean definition with annotation

I'm able to define bean with @Component and add @Requestmapping on that, But I have to define my bean with @Bean because i have multiple beans of the same class. Each bean should have it's own URL. I have tried to add @Requestmapping on my method…
Saeed Shahsavan
  • 35
  • 1
  • 10
0
votes
2 answers

Which annotation to inject list value to list property?

I'm upgrading my app from spring 3.x to 4.3. I'm removing xml configuration and using annotation for it. I'm getting following exception: Initialization of bean failed; nested exception is…
Anil Jagtap
  • 1,740
  • 4
  • 27
  • 44
0
votes
2 answers

Load entire folder of Java Configuration files?

Is there any way to load a entire folder with @Configuration files, the same way XML have: , but with annotations?.
jfzr
  • 374
  • 4
  • 17
0
votes
1 answer

Annotating simple POJO as @Component in Spring for enhancing behavior

I should be able to enhanced some POJO returned by some Spring controllers. To do that and detect those that should be enhanced, I want the developper to be able to put a class annotation on the POJO. The enhancing is doing both by combining a…
Doc Davluz
  • 4,154
  • 5
  • 30
  • 32
0
votes
0 answers

@ComponentScan JSON information replaces the HTML views

Maybe the title is not the best to explain the problem, but I'll try to explain it as best as possible. I have an Spring Boot Application using JPA and MySQL, so in order to check everything worked properly, I made a simple CRUD test for my…
0
votes
0 answers

How can it happen, that Spring @Bean methods were not instrumented?

I found, that in some situations, bean methods of annotated string configuration is called multiple times, although they should be cached. How can it be happen? Being inside one of such method, how can I indentify different nature of calls? May be…
Dims
  • 47,675
  • 117
  • 331
  • 600
0
votes
0 answers

Is it possible to mark with Autowired annotation several entities at once?

Is it possible to mark with Autowired annotation several entities at once? So if have code like this: @Autowired private ClassA classA; @Autowired private ClassB classB; @Autowired private ClassC classC; Can I replace it with something like…
IKo
  • 4,998
  • 8
  • 34
  • 54
0
votes
1 answer

Get property value of annotation (used on a class, not method)

Scenario is something like below... @Component @Migration(description="Test Description", serial="") public class TestUpdate1 { } I need to get the value of description i.e. "Test Description" How can I do that
0
votes
1 answer

Incorrect usage of Stereotypes in Spring and what do they actually do behind the scenes

Can the specialised variants of Spring's @Component be inappropriately used? i.e. if I call my service class @Repository instead of @Service or the reverse. Is there any safeguards against such inappropriate use or is it just a recommendation that…
Chetya
  • 1,267
  • 1
  • 17
  • 31
0
votes
1 answer

How to i configure hibernate annotation based relationship?

I have a table which name is "Pstn" and there is User table. Users does not have to use Pstn table. But some users can use it. So if a pstn has an user we want to see who is. How can i configure hibernate annotations? …
stephan
  • 271
  • 1
  • 4
  • 24
0
votes
1 answer

Spring AOP get annotation value

I am using spring AOP, how can I get values from annotation, Here is my annotation: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @Inherited @Documented public @interface ExecutionMethodProfiler { String value() default…
Michael Biniashvili
  • 500
  • 1
  • 12
  • 24
0
votes
1 answer

Spring AOP only method with annotation

I have this AOP that run on all my application methods, but I want it to run only on methods that annotation with ProfileExecution annotation, how can I do it using this xml
Michael Biniashvili
  • 500
  • 1
  • 12
  • 24
0
votes
1 answer

Parent Application Context in Spring boot

I have the following in non-boot spring application, ear application with 2 wars, How do I implement the same in a spring-boot application In the Service layer: @Configuration @ComponentScan("") @Import({..}) public class BaseConfig…
Anand Rockzz
  • 6,072
  • 5
  • 64
  • 71
0
votes
1 answer

Transaction not getting rolled back with DataSourceTransactionManager and JDBCTemplate

Here are the details - Using JDBCTemplate for query execution. Configuration of required classes in spring application context file is as follows -