[WebDriver]解決報(bào)錯(cuò):tried to access method com.google.common.util.concurrent.SimpleTimeLimiter

UI自動(dòng)化發(fā)現(xiàn)報(bào)錯(cuò):
java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.<init>(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
報(bào)錯(cuò)截圖如下:

問題出在guava 的新版本中

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>25.0-jre</version>
        </dependency>

SimpleTimeLimiter的constructor被定義為private

25.0-jre版本中

Selenium的UrlChecker會(huì)通過constructor去new一個(gè)SimpleTimeLimiter對(duì)象,因此報(bào)錯(cuò)了


selenium包中

降低guava版本到19.0

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>19.0</version>
        </dependency>

SimpleTimeLimiter的constructor被定義為public,問題解決

19.0

最后:guava版本升級(jí)后出現(xiàn)這個(gè)問題,降低版本即可解決,為什么我知道要降低guava版本到19.0?

因?yàn)椴榈経rlChecker所在jar包依賴guava版本是:


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容