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
0 answers

Too many fields which were annotated by @value need to be defined in a bean scope while using spring MVC?

When I was using spring MVC, its annotation features is very difference between XML way. It seems can be more convenient and efficient. BUT, HOW TO INJECT a number of properties into a number of bean made me feel confused. As all we know, in XML…
Vincent
  • 13
  • 5
0
votes
1 answer

Spring Txn - multiple datasources, transactionManaggers, How to decide on a transaction manager in runtime using @Transcational?

I am looking at a way to dynamically pick up a transaction manager instance at runtime. I have a service which is dynamically selecting a DAO reference at runtime based on a parameter like below @Mapper //Spring-MyBatis mapper public interface…
0
votes
0 answers

@Named and @Inject is not working to inject bean of service

I have used to @Named and @Inject several time at office project which works good. I have a personal project where I am implementing in the same way that I had implemented at office work, I am getting below error while deploying the code in tomcat.…
Jacob
  • 420
  • 5
  • 15
0
votes
1 answer

Injecting Beans using Spring Annotations into Constructor Parameters with Property Placeholder

I'm having trouble injecting the Bean type to a constructor parameter from a property file. I am able to inject it by directly passing the value to @Qualifier("beanName") as follows. @Component("circle") public class Circle implements Shape…
Arthas
  • 421
  • 1
  • 6
  • 23
0
votes
2 answers

Spring Configuration with annotations @Autowired not working - step by step

I have performed this steps in order to use annotation based configuration: a) beans.xml
dragonfly
  • 17,407
  • 30
  • 110
  • 219
0
votes
1 answer

Importing Spring @Configurations based on System properties

I am trying to migrate our application from Spring XML based configuration to annotation based configuration. In one of our XML files, say application-config.xml, we have the following line: Here…
Swaranga Sarma
  • 13,055
  • 19
  • 60
  • 93
0
votes
1 answer

Can I specify that a controller level request mapping is not valid for a specific method into a Spring MVC controller class?

I am working on a Spring MVC application and I have the following problem into a controller class that is annotated with @RequestMapping("/profilo/") at class level. So I have something like this: @Controller @RequestMapping("/profilo/") public…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
0
votes
2 answers

Why does my @Before annotation not work in Spring app?

I'm training Spring. My app is not perfect but it's not a case of my problem. I have an Aspect which has to be executed before save() method in book Dao. But when I start JUnit tests in debug mode, first line of Aspect's before method…
RIPI
  • 321
  • 1
  • 9
  • 20
0
votes
1 answer

Spring Accessing configuration - AlreadyBuiltException when setting variable using @Value

I am implementing ldap authentication using Spring Security. It works when I hardcode all the ldap server information in following configuration class. //WebSecurityConfig.java @Configuration @EnableWebSecurity public class WebSecurityConfig extends…
0
votes
1 answer

How to dynamically load different class for JUnit tests?

I've written a couple of JUnit tests to test my REST functionality. Since I only want to test REST (and not the database, domain logic, ..) I made a stub filles with dummy data which stands for the rest of the backend. [EDIT] For example I want to…
Ricardo
  • 335
  • 1
  • 4
  • 13
0
votes
1 answer

How to read blob format file in thymleaf context

I want to store thymleaf template into database instead of file system. Because of If I store into file system, This will be major issue if we need to run several nodes of application to distribute the load across servers. Templates should not be…
bNd
  • 7,512
  • 7
  • 39
  • 72
0
votes
1 answer

Spring MVC 4 java config does not recognize localization change

This is my project structure: and this is Spring root config: @EnableWebMvc @Configuration @ComponentScan({ "com.rgh.*" }) @EnableTransactionManagement @Import({ SpringSecurityConfig.class }) public class SpringWebConfig extends…
0
votes
1 answer

how to add custom filter to spring security filter chain with custom filter mapping?

I want to check captcha if use wants to be logined and if captcha was correct, call filterChain.doFilter() to resume authentication and if captcha was incorrect rediredt user to login page to re-enter username, password and captcha. So, i want to…
0
votes
2 answers

Controller registers, but gets 404 when returning data

This is initializer for Spring. I'm not using any .xml files. import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; import…
user1838913
  • 103
  • 6
0
votes
1 answer

How to autowire @service class ? No qualifying bean of type found for dependency

What are the prerequisites to auto-wired any class without implementing any interface? Class Diagrams MainClass -> Annotation used : @SpringBootApplication @EnableTransactionalManagement DatabaseConfig -> @Configuration…