SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/eclipse-jee-2021-03-R-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/D:/eclipse-jee-2021-03-R-win32-x86_64/eclipse/configuration/org.eclipse.osgi/6/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/eclipse-jee-2021-03-R-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/D:/eclipse-jee-2021-03-R-win32-x86_64/eclipse/configuration/org.eclipse.osgi/6/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.edu:MavenProject2024 >----------------------
[INFO] Building MavenProject2024 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.7:prepare-agent (prepare-agent) @ MavenProject2024 ---
[INFO] argLine set to -javaagent:C:\\Users\\86135\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.7\\org.jacoco.agent-0.8.7-runtime.jar=destfile=D:\\eclipse-workSpace\\MavenProject2024\\target\\jacoco.exec
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenProject2024 ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ MavenProject2024 ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 6 source files to D:\eclipse-workSpace\MavenProject2024\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.592 s
[INFO] Finished at: 2024-11-20T16:03:01+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project MavenProject2024: Fatal error compiling: 错误: 无效的目标发行版:15.0.2 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
1、对于第一个错误信息 “SLF4J: Class path contains multiple SLF4J bindings” :
表示项目类路径中包含了多个SLF4J(Simple Logging Facade for Java)的绑定实现。SLF4J是一个用于日志管理的门面,它允许使用统一的接口来调用各种日志框架。但是当项目的类路径上有多个SLF4J的实现时,它不知道应该使用哪一个,因此会给出警告。
查看报错提示,可以发现错误的具体信息如下:
- 有两个SLF4J的绑定:
- 一个位于Eclipse插件的目录下:
slf4j-simple-1.7.5.jar- 另一个位于Eclipse配置的OSGi框架中:
org/slf4j/impl/StaticLoggerBinder.class解决这个问题的方法通常有以下几种:
排除冲突的依赖:在Maven的
pom.xml文件中,可以排除掉那些包含SLF4J绑定的依赖项。找到引入了多个SLF4J绑定的依赖,并使用<exclusions>标签排除它们。使用依赖管理:在
pom.xml中使用<dependencyManagement>来确保只使用一个版本的SLF4J绑定。shade插件:如果无法通过排除依赖来解决冲突,可以使用Maven的shade插件来重新打包你的应用程序,并排除掉不需要的绑定。
2、对于第二个错误信息“无效的目标发行版:15.0.2”,这通常表示项目指定的Java编译版本不正确或不可用。
检查Java版本:确保Eclipse环境中配置的JDK版本是正确的,并且项目的
pom.xml文件中的maven-compiler-plugin配置的source和target版本与设置的JDK版本兼容。更新Maven插件:确保
maven-compiler-plugin是最新版本,并且配置正确。检查Eclipse设置:在Eclipse中,检查项目的构建路径(Build Path)设置,确保指向正确的JDK。
3、这里的解决方法就是去设置编译器插件和排除SLF4J绑定:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source> <!-- 根据自己设置的JDK版本来设置 -->
<target>1.8</target> <!-- 根据自己设置的JDK版本来设置 -->
</configuration>
</plugin>
<!-- 排除SLF4J绑定 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<failOnWarning>true</failOnWarning>
<ignoreNonCompile>true</ignoreNonCompile>
<usedDependencies>
<usedDependency>org.slf4j:slf4j-api</usedDependency>
</usedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
4、最后执行mvn clean,清理一下再去执行要执行的命令,一般就ok了


853

被折叠的 条评论
为什么被折叠?



