spring boot項目升級到2.0.1,提示java.lang.ClassNotFoundException: org.apache.log4j.Logger錯誤

來源:互聯網
上載者:User

標籤:logging   相容   圖片   分享   img   區別   ons   lease   bubuko   

首先肯定是版本出現了一點相容問題

所以我就進入項目,查看依賴樹,cd到項目目錄下,mvn dependency:tree

我看到我的項目原先是1.5.9和現在2.0.1的區別在於org.slf4j的依賴不全

【1.5.9.release】

【2.0.1.release】

那麼問題簡單了,我就把原先用到的日誌依賴全部手動添加1.7.25版本

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
因為項目都是用logback,所以就排除log4j就行了

spring boot項目升級到2.0.1,提示java.lang.ClassNotFoundException: org.apache.log4j.Logger錯誤

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.