javax.annotation classes and Java 11 JDK
For me the problem was in a conflict between libs: javax.annotations-api^1.3.2 and jsr250-api:1.0. There is a javax.annotation.@Resource annotation in jsr250-api WITHOUT lookup() method! On some running environments jsr250's @Resorse was loaded first, on others - javax.annotations-api's. In the first case my error took place:
Post-processing of merged bean definition failed; nested exception is java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String;
Solving: get rid of one of libs using maven exclusion.
When migrating up ahead 3 releases of Java, the first thing one should consider is to update all the major dependencies.
maven-compiler-plugin
-> current version is 3.8.1
,
2.5.1 is 7 years old.
Try the following to resolve this error:
java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String;
Keep the dependency:
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
And explicitly add it as a module:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
<compilerArgs>
<arg>--add-modules</arg>
<arg>java.xml.ws.annotation</arg>
</compilerArgs>
</configuration>
</plugin>