【java – 运行youtube重新审阅注释时的权限不足】教程文章相关的互联网学习教程文章

java-如何在注释处理器中捕获常量表达式?【代码】

我希望能够检测到以下代码示例中如何初始化name *变量以及是否内联了name *.那可能吗?@FancyAnnotation public static final String name1 = new String("B1");@FancyAnnotation public static final String name2 = "B2";谢谢.解决方法:ElementVisitors可用于检测常量初始化程序.boolean usesConstantValue = element.accept(new ConstantValueDetector(), null);...private static class ConstantValueDetector extends SimpleE...

java-如何在不使用注释的情况下创建Spring控制器?【代码】

我正在学习Spring Core认证,但对此问题有一些疑问:What is the @Controller annotation used for? How can you create acontroller without an annotation?因此,我知道@Controller注释指示特定的类充当控制器的角色. @Controller注释充当带注释的类的构造型,指示其作用.调度程序扫描此类带注释的类以查找映射的方法,并检测@RequestMapping注释. 所以控制器类是这样的:@Controller public class AccountController {@RequestMappi...

java-如何在自定义约束验证器中使用注释元素【代码】

我在名为CGC的项目中编写了一个自定义注释:@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @Constraint(validatedBy = CGCValidator.class) public @interface CGC {String message() default "{person.cgc.error}";Class<?>[] groups() default {};Class<? extends Payload>[] payload() default {};boolean canBeNull() default false;@Target({ METHOD, FIELD, ANNOTA...

java-注释,用于检测字符串参数顺序错误的方法调用【代码】

我们有一个使用很多字符串的大型应用程序: >序列号>产品名称>订单号>供客户参考> …还有更多… 不幸的是,我们的开发人员只是人类.有时在调用方法时,字符串值会混淆.例如:// this method public void addProductToOrder(String order, String productname, String serialnumber);// should be called like: addProductToOrder(order, productname, serialnumber);// but is sometimes mistakenly called as: addProductToOrder(pr...

java-如何使用自定义注释存储和加载加密值【代码】

我是Java自定义注释的新手I am developing a custom annotation which encrypt and decrypt a stringand store it in database using spring and mongodb and for encryption I am using jasypt.我没有确切的步骤去做. 我的代码. 实体public class Demo {@Idprivate Long id;private String somethingPublic;@EncryptDemo()private String somethingPrivate;//getter setter}自定义注释@Target({ ElementType.METHOD, ElementType....

在Java 8中更改字段注释的注释值【代码】

我认为标题说明了问题.这是一些代码:import static org.junit.Assert.assertEquals; import java.lang.annotation.*;public class Main {public static void main(String[] args) throws Exception {assertEquals("foo", Main.class.getDeclaredMethod("myMethod").getAnnotation(Anno.class).param());// the magic here -> set to barassertEquals("bar", Main.class.getDeclaredMethod("myMethod").getAnnotation(Anno.class)....

将Java 8 Lambda与注释结合【代码】

考虑以下代码:public class MyTest { public void sayHello(Supplier<String> myGetter) {System.out.println("Hello " + myGetter.get()); }public static void main(String[] args) {Person person = new Person("Michal", "Lefler");MyTest myTest = new MyTest();List<Supplier<String>> suppliers = new ArrayList<>();suppliers.add(person::getName);suppliers.add(person::getLastName);suppliers.forEach(myTest::sayHel...

java-@EnableIntegration注释用途【代码】

我将项目从XML Spring Integration配置迁移到Java DSL.我事先准备了一些集成测试.因此,我可以逐步安全地进行迁移. 在移动此XML连接器定义后的某个时刻<int:publish-subscribe-channel id="upstreamAckChannel" />Java Spring配置@Bean public PublishSubscribeChannel upstreamAckChannel() {return MessageChannels.publishSubscribe().get(); }我的集成流程停止将测试消息重新发送到我的测试. 经过一段时间的试验,我意识到我的Sp...

有什么方法可以强制使用Java中的某些特定注释和某些特定方法【代码】

类实现接口确保接口中的所有方法都在类中定义,同样,有任何方法可以告诉JVM在实现类时应使用一些特定的注释.考虑以下界面public interface TestClass{@BeforeClasspublic void setup();@AfterClasspublic void tearDown(); }接下来是实现类public class TestScripts implements TestClass{@BeforeClasspublic void setup(){/*method body*/}@AfterClasspublic void tearDown(){/*method body*/} }我想要的是,如果@BeforeClass批注未...

java-Spring的@Scheduled注释如何工作?【代码】

在我的应用程序中,我在3个单独的类中有3个预定的方法:@Component public class ClassA { @Scheduled(fixedDelay = 5000L)public void methodA(){//do task "A"} }@Component public class ClassB { @Scheduled(fixedDelay = 5000L)public void methodB(){//do task "B"} }@Component public class ClassF { @Scheduled(fixedDelay = 5000L)public void methodF(){//do task "F"} }在应用程序applicationContext中有以下几行:<tas...

java-Spring Framework AliasFor注释难题【代码】

我正在使用Spring Boot(1.3.4.RELEASE),并且对4.2中引入的新@AliasFor注释有疑问 考虑以下注释: 视图@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Component public @interface View {String name() default "view"; }综合@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @View public @interface Composite {@AliasFor(annotation = View.class, attribute = "name")String value() default...

为什么我无法从已加载的Java类中检测注释?【代码】

我有一个插件,我想从我的maven项目中访问模型包的类列表.到目前为止,我只是这样做将类加载到插件中:try {runtimeClasspathElements = project.getRuntimeClasspathElements();} catch (DependencyResolutionRequiredException e) {// TODO Auto-generated catch blocke.printStackTrace();}URL[] runtimeUrls = new URL[runtimeClasspathElements.size()];for (int i = 0; i < runtimeClasspathElements.size(); i++) {String ele...

java-在Kotlin项目中使用@Value注释时出现编译器警告【代码】

在后期初始化中,是否可以使用Kotlin语言中的任何类型代替java.lang.Integer,以便不会收到编译器警告? 假设我有一个像这样的课程:class SomeClass {@Value(#{config['poolCapacity']?:'5000'})lateinit var somePool: Integer }我不能使用Kotlin的Int类型,因为它是原始类型,而lazeint不接受它. 如果我坚持使用java.lang.Integer,它可以正常工作,但是我得到了这种编译器警告:SomeClass.kt: (20, 24): This class shouldn’t be us...

java-在Spring中创建新实例与使用范围原型注释之间的区别【代码】

我的应用程序正在侦听交换(使用rabbitMQ),希望接收一些API数据,然后将其重定向到相关位置. 当目的是打开一个新线程并通过每次创建RestClient来发送请求时,我正在使用rxJava来订阅这些更改.它会接收数据,解析,发送数据,然后将响应发送回队列. 我的问题是我想每次都创建我的RestClient的新实例.想过使用Spring Scope注释:@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE),但似乎无法理解如何使用它,如果每次使用新的RestCl...

java-在AnnotationProcessor中获取带注释的类的包名称【代码】

我有一个用AnnotationProcessor处理的类.在此过程中,我有一个javax.lang.model.element.Element实例,在这里我可以通过.getSimpleName()获取带注释的类的名称.我知道需要的是带注释的类的packageName(com.software.cool). 知道如何通过API来接收它吗?解决方法:您绝对不想使用getQualifiedName:在某些情况下,它将产生令人惊讶的结果.例如,不可能区分包名称的最后部分和内部类的父类:在“ java.util.Map.Entry”中,“ Map”是包名称...

运行 - 相关标签
注释 - 相关标签