如何自定义Intellij在我自己的注释中提供了值
我正在研究春季,当我使用scope
班级注释时,Intellij帮助我为value
属性(字符串)提供不同的选项,示例
如何开发自己的注释来预先定义这些值?
另外,对于@value
注释,Intellij从哪里获得值?还是只是春季的“锐利”?
编辑:这是专门用于注释的。通常,在春季建议的左侧,右边是我的班级。如何做左边?
package ru.max.mypacktest;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyRealName {
String value() default "";
}
I'm studying Spring and when I use the Scope
annotation for a class, IntelliJ helps me providing different options for value
property (String), example
How can I develop my own annotation to predefine those values?
Also for the @Value
annotation, where does IntelliJ get the values from? or is it just a "sharpening" for Spring?
Edit: This is meant specifically for annotations. In general, on the left as suggested in Spring, on the right is my class. How to do as on the left?
package ru.max.mypacktest;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyRealName {
String value() default "";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来没有配置它的默认方法,但是您可以尝试使用 live模板功能作为解决方法。
创建以下实时模板:
Looks like there is no default way to configure it but you can try using Live Templates feature as a workaround.
Create the following Live Template:
Call it in your code: