0

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 behind @Bean but it wasn't allowed. So how can i add @Requestmapping on @Bean? Here is my Code:

@Bean("documentSearchServiceImpl")
public SearchServiceImpl documentSearchService(@Autowired @Qualifier("documentSearchEngine") SearchEngine searchEngine) {
 return new SearchServiceImpl(searchEngine); 
}
Saeed Shahsavan
  • 35
  • 1
  • 10

1 Answers1

0

Instead using @Bean use

@Controller

Smit
  • 395
  • 3
  • 12
  • Look at my code: @Bean("documentSearchServiceImpl") public SearchServiceImpl documentSearchService(@Autowired @Qualifier("documentSearchEngine") SearchEngine searchEngine) { return new SearchServiceImpl(searchEngine); } So as you said i`ve changed @Bean to @Controller The result is a compile error: The annotation @Controller is disallowed for this location – Saeed Shahsavan Apr 19 '17 at 08:13