簡體   English   中英

使用Spring 4 PropertySource時找不到可重復的內容

[英]Repeatable not found when using Spring 4 PropertySource

我們將Spring 4.0.1.RELEASE與jdk6結合使用(這是固定的)。 當然,我們使用@PropertySource注釋在Java中完成了配置。 當我們使用gradle編譯項目時,這會導致惱人的警告消息:

org \\ springframework \\ context \\ annotation \\ PropertySource.class(org \\ springframework \\ context \\ annotation:PropertySource.class):警告:在類型'java.lang.annotation.Repeatable'中找不到annotat ion方法'value()':class找不到java.lang.annotation.Repeatable的文件

這是由於使用not(在jdk6中)現有的Repeatable類引起的,我很高興它只是一個警告。 我喜歡gradle的干凈輸出,這只是令人討厭,因為它可能會混淆其他“真正的”警告(如checkstyle ......)。

也許任何人都遇到了同樣的問題,並為這種情況得到了一個(不是那么多黑客)解決方案。 我只想再次看到干凈的輸出。

我認為問題在於,在Spring 4中 ,它們使用@Repeatable注釋,該注釋僅在Java 8中引入。

因此,如果您不使用Java 8,您將繼續看到此問題,至少在修復此問題之前。

順便說一下,這也阻止了在舊版JDK中使用@Scheduled注釋而不是Java 8.我希望它很快就能修復。

僅供記錄:使用

@PropertySources(@PropertySource("classpath:path/to/config"))

擺脫異常。

積分轉到: http//www.javacodegeeks.com/2013/11/how-to-using-propertysource-annotation-in-spring-4-with-java-7.html

我想如果您只是想擺脫警告,您可以使用自定義記錄器實現此目的: http//www.gradle.org/docs/current/userguide/logging.html

我會檢查當前的實現,並將其包含在過濾掉您要忽略的警告的內容中,並將其他所有內容保持不變。

擺脫Java 8下面的警告的解決方法是使用以下方法而不是@Scheduled注釋:

@PostConstruct
public void setupTaskScheduler() throws FileNotFoundException {
    taskScheduler = new ConcurrentTaskScheduler();

    taskScheduler.schedule(new Runnable(...), new CronTrigger("0 0 * * * *"));    
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM