@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Transactional
@Service(value = "AAA")
public @interface TransactionalService {
}
@TransactionalService
public class AService {
public void save(){
System.out.println("save");
}
}
环境:
spring-boot 2.7.6
我自定义了一个注解,然后 @Service(value = "AAA"),接下来使用这个注解, 但是这个 AService 对象的名称是 AService,而不是 AAA
这是哪里有问题?
![]() |
1
Bromine0x23 154 天前
value 没法这样设置,要在自定义注解上添加一个 value 属性,然后用 @AliasFor 标注
|
2
running17 154 天前 ![]() |
3
urnoob 154 天前
其实我有个问题 op 和 2l 这种做法有什么场景场景要用的 ? 就为了省一个注解?
|
5
sulinwork 154 天前
我这样写是生效的 不知道为啥楼主不行
|
![]() |
8
Bromine0x23 154 天前
|