sunmingtao / sample-code

3 stars 4 forks source link

org.slf4j.simple.SimpleServiceProvider does not define or inherit an implementation of the resolved method abstract getRequesteApiVersion() #347

Closed sunmingtao closed 4 months ago

sunmingtao commented 4 months ago

A warning shows. It is related to the PDFBox library

Unexpected problem occured during version sanity check
Reported exception:
java.lang.AbstractMethodError: Receiver class org.slf4j.simple.SimpleServiceProvider does not define or inherit an implementation of the resolved method abstract getRequesteApiVersion()Ljava/lang/String; of interface org.slf4j.spi.SLF4JServiceProvider.
    at org.slf4j.LoggerFactory.versionSanityCheck(LoggerFactory.java:294)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:141)
    at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:418)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:404)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:353)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:273)
    at org.apache.pdfbox.pdmodel.PDDocument.<clinit>(PDDocument.java:95)
    at au.gov.nla.banjo.services.PdfBoxPlayground.main(PdfBoxPlayground.java:24)
sunmingtao commented 4 months ago

I resolved it by excluding slf4j-api brought in by HikariCP

<dependency>
    <groupId>com.zaxxer</groupId>
    <artifactId>HikariCP</artifactId>
    <version>5.0.1</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>