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

Configurable Component Scan

Is there a way to make the component scan configurable externally or through an intermediate resolver class? My requirement is that a common library should include one or more of other smaller facilities (each having their own controller, services…
Arnab Gupta
  • 677
  • 1
  • 5
  • 9
0
votes
0 answers

@Configuration in child project not working in parent

I have a parent application Application1 which loads beans based on Spring XML configuration. I have child application Application2 (included/referred on Application1) with @Configuration based fully annotated spring java file. When I deploy…
DecKno
  • 293
  • 1
  • 5
  • 21
0
votes
0 answers

Spring Controller Method annotated with @ResponseBody, @GET takes long time to generate respone

Spring Controller Method annotated with @ResponseBody takes long time to generate JSON response when I annotate it with @GET HTTP Method annotation While the same method when annotated with @POST (keeping @ResponseBody annotation intact), the JSON…
Amit Dube
  • 947
  • 4
  • 10
  • 23
0
votes
1 answer

JMX with spring without XML configuration, 100% annotation based?

I am using JMX in Spring application with XML configuration:
DecKno
  • 293
  • 1
  • 5
  • 21
0
votes
2 answers

In Spring mvc How to add add set values to mysql

My goal : In Spring MVC I have to save mobile phone contact list into database. example: phone1 sonia 2554654 work 2554654 home multiple phone_number with multiple phone_Number type contacts…
user_apr
  • 719
  • 2
  • 10
  • 27
0
votes
1 answer

How can I correctly set a SessionAttribute into a Spring MVC Controller class and retrieve and use it into another Controller class?

I am pretty new in Spring MVC and I have the following problem. Into an home() controller method defined into a class named **HomeController I retrieve an object using a service. This object have to be put as Session Attribute so it can be used from…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
0
votes
1 answer

Could not autowire field on extending DAO and Manager interface

Hi my application was working fine, but on extending my Manager and Dao interface I am getting the error. I have tried the solution (changing to )…
Ishan
  • 62
  • 2
  • 8
0
votes
1 answer

do all @configuration classes need to be specified in either getRootConfigClasses or getServletConfigClasses?

In spring mvc project, I use purely java config style to configure the servlet container. In a AbstractAnnotationConfigDispatcherServletInitializer subclass, I override two methods, getRootConfigClasses and getServletConfigClasses, they load beans…
James Hao
  • 765
  • 2
  • 11
  • 40
0
votes
0 answers

can I use Aspect to switch EntityManager, Service and Repository?

I have two EntityManagers for two DataSources with two Services, Repositories and some entities. LocalContainerEntityManagerFactoryBean masterEntiryManager; LocalContainerEntityManagerFactoryBean replicaEntiryManager; ... MasterBrickRepository…
mikezang
  • 2,291
  • 7
  • 32
  • 56
0
votes
1 answer

Why are some @Enable* annotations picked up without @Configuration?

I have the following classes in different packages: @EnableWebMvc public class ActuatorConfig { // empty // only needed to get REST so I can hit Actuator endpoints } @Component // REMOVE THIS LINE? @EnableBatchProcessing public class…
0
votes
1 answer

Way to inject generic bean that have constructor with generic class argument

I have generic class ObjectDaoReflect it work with reflaction, because of type erasure it have constructor with generic class parameter public ObjectDaoReflect(Class objectClass). My idea is add custom logic before bean…
Zilian
  • 1
  • 2
0
votes
2 answers

spring-test-dbunit @DatabaseSetup

I have a problem with @DatabaseSetup annotation. When I'm using it, I have data(after executing @DatabaseSetup) in transaction, which I don't needed And Annotation @Transactional(Transactional.TxType.NEVER) is not working for some reason. Any idea…
Heng
  • 83
  • 2
  • 12
0
votes
0 answers

Getting the error:- org.springframework.beans.factory.UnsatisfiedDependencyException

I am new to Spring and we are using a Spring Batch to process jobs I am posting my whole code below,Please share you knowledge:- This is the Main class file Name with SpringBatchAdmin:- @Configuration @EnableAutoConfiguration(exclude = {…
yadav_1992
  • 43
  • 2
  • 11
0
votes
1 answer

Autowire annotation working in Controller but not anywhere else?

I am using Spring 4.1.1. I have the following in my spring-dispatcher-servlet.xml
0
votes
1 answer

reading properties file in jsp using annotation spring 4

I need to do this, with annotation, withouth using xml file. < bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > < property name="locations" > < list > …