[英]Custom Annotation Processor working in Maven but not in eclipse
我有一個示例項目中使用的自定義注釋處理器。 我在示例項目的pom.xml文件中添加了以下內容
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<annotationProcessors>
<annotationProcessor>com.******.CustomAnnotationProcessor</annotationProcessor>
</annotationProcessors>
<compilerArgs>
<arg>-Amyarg=${project.artifactId}</arg>
</compilerArgs>
</configuration>
</plugin>
然后,我在application.properties文件中聲明參數,如下所示:
@myarg@.someVal=foobar
並按如下方式訪問它:
public class TestClass {
@Value("${@myarg@.someVal}")
private String testVal;
public void testMethod(){
System.out.println(testVal);
}
}
它在Intelli J中工作正常,因為testVal輸出為foobar。 但是,在eclipse中,出現以下錯誤:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘testClass': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder ‘@myarg@.someVal’ in string value "${@myarg@.someVal}"
我知道Eclipse使用自己的編譯器,而Maven可能使用javac。 如何使此自定義注釋也適用於Eclipse?
我也有這個問題。
99%的溶液如gyan所述。
最后1%是用於日食的,我需要“ jar”文件,需要在“工廠路徑”中指定所有需要的jar文件。
對於我的項目,這意味着
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.