Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Idea 12, How do I indicate some spring files are used only for Tests

I have multiple spring config files. Few are for testing.

Throughout the code base Idea12 has highlighted all Autowired beans as "There is more than one bean of XXX type".

How do I configure IDEA so that it correctly identifies the instances to be used in testing and in production?

like image 660
Ram Avatar asked Dec 18 '12 14:12

Ram


1 Answers

It's supposed to be fixed in the next update. But meantime just go the Project Structure -> Facets -> Spring and remove some of the application context configurations that include ones already defined.

For instance, I have 2 modules in my project: Core (jar) and Webapp (war) which depends on the Core. When both are included into the Spring facet in IDEA the beans defined in the Core application context are seen twice by IDE: 1st time directly from Core application context and 2nd time from Webapp context which includes Core context. Since Core module beans are already visible in Web module the Spring facet for Core can be removed and the issue will be fixed.

like image 149
Alex Vayda Avatar answered Nov 15 '22 13:11

Alex Vayda