同时检测到log4j-over-slf4j.jar和slf4j-log4j12.jar

我使用了geotools库,在我的项目中,我已将所有依赖项添加到构建路径中,

从[Sourseforge。] [1]下载库。将相同的库添加到库中,当我尝试执行应用程序时,出现以下错误。

    SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. 
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.hsqldb.DatabaseManager.filePathToKey(Unknown Source)
    at org.hsqldb.DatabaseManager.getDatabaseObject(Unknown Source)
    at org.hsqldb.DatabaseManager.getDatabase(Unknown Source)
    at org.hsqldb.DatabaseManager.newSession(Unknown Source)
    at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
    at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
    at org.hsqldb.jdbc.JDBCDataSource.getConnection(Unknown Source)
    at org.hsqldb.jdbc.JDBCDataSource.getConnection(Unknown Source)
    at org.geotools.referencing.factory.epsg.DirectEpsgFactory.getConnection(DirectEpsgFactory.java:3529)
    at org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createBackingStore(ThreadedEpsgFactory.java:437)
    at org.geotools.referencing.factory.DeferredAuthorityFactory.getBackingStore(DeferredAuthorityFactory.java:114)
    at org.geotools.referencing.factory.BufferedAuthorityFactory.isAvailable(BufferedAuthorityFactory.java:218)
    at org.geotools.referencing.factory.DeferredAuthorityFactory.isAvailable(DeferredAuthorityFactory.java:100)
    at org.geotools.util.factory.FactoryRegistry.isAvailable(FactoryRegistry.java:808)
    at org.geotools.util.factory.FactoryRegistry.isAcceptable(FactoryRegistry.java:631)
    at org.geotools.util.factory.FactoryRegistry.lambda$getFactories$0(FactoryRegistry.java:300)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
    at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812)
    at java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:294)
    at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206)
    at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:161)
    at java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:300)
    at java.util.Spliterators$1Adapter.hasNext(Spliterators.java:681)
    at org.geotools.util.LazySet.isEmpty(LazySet.java:98)
    at org.geotools.referencing.factory.ManyAuthoritiesFactory.<init>(ManyAuthoritiesFactory.java:115)
    at org.geotools.referencing.DefaultAuthorityFactory.getBackingFactory(DefaultAuthorityFactory.java:114)
    at org.geotools.referencing.DefaultAuthorityFactory.<init>(DefaultAuthorityFactory.java:67)
    at org.geotools.referencing.CRS.getAuthorityFactory(CRS.java:253)
    at org.geotools.referencing.CRS.decode(CRS.java:533)
    at org.geotools.referencing.CRS.decode(CRS.java:447)
    at org.geotools.dev.SelectApp.fromBytes(SelectApp.java:153)
    at org.geotools.dev.SelectApp.selectAll(SelectApp.java:81)
    at org.geotools.dev.SelectApp.main(SelectApp.java:96)
Caused by: java.lang.RuntimeException: Failed to instantiate Log4j Logger
    at org.hsqldb.lib.FrameworkLogger.<init>(Unknown Source)
    at org.hsqldb.lib.FrameworkLogger.getLog(Unknown Source)
    at org.hsqldb.lib.FrameworkLogger.getLog(Unknown Source)
    at org.hsqldb.lib.FileUtil.<clinit>(Unknown Source)
    ... 33 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    ... 37 more
Caused by: java.lang.ExceptionInInitializerError
    at org.apache.log4j.Logger.getLogger(Logger.java:39)
    ... 41 more
Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
    at org.apache.log4j.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:49)
    ... 42 more

我尝试过的沙发…,

正如在此[接受的答案] [2]中所建议的那样,我添加了排除项。仍然有相同的错误。

我对它们没有任何依赖性,即使我已经删除了两个jar文件,错误仍然保持不变!

我的Pom.xml

.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.geotools</groupId>
   <artifactId>tutorial</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
   <name>tutorial</name>
   <url>http://maven.apache.org</url>
   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <geotools.version>24-SNAPSHOT</geotools.version>
   </properties>
   <dependencies>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.11</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.geotools</groupId>
         <artifactId>gt-shapefile</artifactId>
         <version>${geotools.version}</version>
      </dependency>
      <dependency>
         <groupId>org.geotools</groupId>
         <artifactId>gt-swing</artifactId>
         <version>${geotools.version}</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/log4j/log4j -->
      <!-- <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>1.2.17</version>
      </dependency> -->
   </dependencies>
   <repositories>
      <repository>
         <id>osgeo</id>
         <name>OSGeo Release Repository</name>
         <url>https://repo.osgeo.org/repository/release/</url>
         <snapshots>
            <enabled>false</enabled>
         </snapshots>
         <releases>
            <enabled>true</enabled>
         </releases>
      </repository>
      <repository>
         <id>osgeo-snapshot</id>
         <name>OSGeo Snapshot Repository</name>
         <url>https://repo.osgeo.org/repository/snapshot/</url>
         <snapshots>
            <enabled>true</enabled>
         </snapshots>
         <releases>
            <enabled>false</enabled>
         </releases>
      </repository>
   </repositories>
   <exclusions>
      <exclusion>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-log4j12</artifactId>
      </exclusion>
      <exclusion>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
      </exclusion>
   </exclusions>
   <build>
      <plugins>
         <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
               <source>1.8</source>
               <target>1.8</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

  [1]: https://sourceforge.net/projects/geotools/files/
  [2]: ht

tps://stackoverflow.com/questions/20117720/detected-both-log4j-over-slf4j-jar-and-slf4j-log4j12-jar-on-the-class-path-pree