我是Java 17的新手,我尝试用Java 17构建我的项目,我得到了下面的错误,我如何修复它。
[WARNING] Error injecting: org.apache.maven.plugins.resources.ResourcesMojo
com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) [Guice/NullInjectedIntoNonNullable]: null returned by binding at LocatorWiring
but the 1st parameter of DefaultMavenResourcesFiltering.<init>(DefaultMavenResourcesFiltering.java:66) is not @Nullable
at LocatorWiring
at DefaultMavenResourcesFiltering.<init>(DefaultMavenResourcesFiltering.java:66)
\_ for 1st parameter
at ClassRealm[plugin>org.apache.maven.plugins:maven-resources-plugin:3.3.1, parent: ClassLoaders$AppClassLoader@2a139a55]
\_ installed by: WireModule -> PlexusBindingModule
while locating DefaultMavenResourcesFiltering
while locating Object annotated with *
while locating ResourcesMojo
Learn more:
https://github.com/google/guice/wiki/NULL_INJECTED_INTO_NON_NULLABLE
1 error
======================
Full classname legend:
======================
ClassLoaders$AppClassLoader: "jdk.internal.loader.ClassLoaders$AppClassLoader"
DefaultMavenResourcesFiltering: "org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering"
LocatorWiring: "org.eclipse.sisu.wire.LocatorWiring"
PlexusBindingModule: "org.eclipse.sisu.plexus.PlexusBindingModule"
ResourcesMojo: "org.apache.maven.plugins.resources.ResourcesMojo"
WireModule: "org.eclipse.sisu.wire.WireModule"
========================
End of classname legend:
========================
字符串
这里也是我的POM看起来像什么
<packaging>war</packaging>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-openfeign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>4.0.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2022.0.4</version>
<type>pom</type>
<!-- <scope>import</scope>-->
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.openfeign/feign-httpclient -->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>12.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.0.Final</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.10.00</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jacoco/jacoco-maven-plugin -->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version> <!-- Make sure this version is compatible -->
</plugin>
<!-- Other plugins -->
</plugins>
</build>
型
我试着从不同的maven版本改变仍然没有工作。
1条答案
按热度按时间zazmityj1#
错误似乎是由于与Java 17和您正在使用的Maven资源插件不兼容而引起的。
Java 17使用JEP 396对JDK的内部API进行了强封装。一些过去依赖于这些内部API的库和插件,如果没有更新,可能会在Java 17下失败。
以下是解决此问题的一些步骤:
1.更新Maven:确保您使用的是支持Java 17的最新版本的Maven。理想情况下,是Maven 3.8.4或更高版本。
1.更新Maven资源插件:您使用的maven-resources-plugin版本3.3.1可能与Java 17不完全兼容。请将其更新为支持Java 17的更新版本。将其替换为:3.3.0
检查这些之后如果你仍然遇到问题,考虑为Java 17创建一个特定的Maven配置文件。这样,你就可以有特定的插件配置和依赖项,只有在使用Java 17构建时才会激活。