Spring Meta Annotations

Does anyone know that the Spring JAR ( and where to find it! ) Contains functions for Spring so-called "meta annotations". As shown in this article, these cool β€œnew” (well, sorted) constructs allow you to use this code:

 @Service @Scope("request") @Transactional(rollbackFor=Exception.class) @Retention(RetentionPolicy.RUNTIME) public @interface MyService { } @MyService public class RewardsService { … } 

Basically, I have a Swing app that doesn't use Spring. I have a sudden change in requirements that would be made extremely easy if I could use these annotations.

So, I'm just looking for the smallest, minimally invasive Spring JAR where this functionality can be found. If you need absolute necessity, I can use the entire Spring JAR , but that would be a very difficult decision. It would be nice if Spring released a smaller JAR with less features.

I swing the Maven Repo and see a spring-core that contains a package called:

org.springframework.core.annotation

But when checking API docs, this doesn't seem to be what I need ...

Auxiliary question: can I even use these meta annotations as standalone constructs, or should I use them together with, for example, Spring DI or AOP or other main parts of the Spring frame?

Thanks in advance!

+7
source share
2 answers

The annotations you want will be associated with the bank with which it is associated. For example, the annotation org.springframework.transaction.annotation.Transactional will be in the spring-transactions artifact.

Meta annotations are actually no different from regular annotations, except that Spring now detects annotations in annotations, whereas this was not the case before. Whether the annotations β€œwork” or not depends on what they are looking for (in this case, something in the context of Spring).

For further reading, see Annotation-Based Configuration Console in the Spring Help.

+4
source

There is a github project that is trying to provide meta annotation functionality. https://github.com/dblevins/metatypes/

+1
source

All Articles