Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency on Spring's annotations

I have annotated my classes with @Repository, @Resource, @Component, @Service annotations but these classes must run in 2 environments. The first environment is Spring 2.x based while the other has no spring at all. I'm sure the code will fail without the spring jars & I want to know ideas from you on how I can retain the annotations but still work in both environments

like image 290
Jacques René Mesrine Avatar asked Mar 18 '10 08:03

Jacques René Mesrine


1 Answers

To be able to use the annotations that you mention, or really, let Spring use them for you so you get the benefit, you need to use at least Spring 2.5.x, that's when they were introduced.

Furthermore, annotations are not required to be on the classpath. They will just be ignored. Since when you are using spring 2.0 there will be no code that tries to 'scan' for them.

like image 135
Hans Westerbeek Avatar answered Sep 29 '22 13:09

Hans Westerbeek