Я получаю следующий вывод при выполнении тестов весенней загрузки с использованием Java 11.
Я также получаю ту же ошибку при выполнении
java -jar target\application.jar
Так что это не просто проблема maven.
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist.
The attempt was made from the following location:
org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.<init>(CommonAnnotationBeanPostProcessor.java:627)
javax.annotation.Resource.lookup()Ljava/lang/String; but it does not exist. Its class, javax.annotation.Resource, is available from the following locations:
jar:file:/C:/Users/X/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar!/javax/annotation/Resource.class
jar:file:/C:/Users/X/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar!/javax/annotation/Resource.class
It was loaded from the following location:
file:/C:/Users/X/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
Кажется, загружается неправильная зависимость?
У меня есть эти конфигурации в pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<dependencies>
...
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
с конфигурацией сборки ...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version> <!-- or newer version -->
<configuration>
<source>11</source> <!-- depending on your project -->
<target>11</target> <!-- depending on your project -->
<compilerArgs>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<!-- other annotation processors -->
</annotationProcessorPaths>
</configuration>
</plugin>
Как правильно исправить это, чтобы тесты выполнялись корректно из коробки?
Действие:
Исправьте путь к классу вашего приложения, чтобы оно содержало одну совместимую версию javax.annotation.Resource
1024 * редактировать *
Я также пробовал:
<build>
<extensions>
<extension>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</extension>
<extension>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>