Skip to content

SpringBoot3.x 使用GraalVM打包为Native时报错:org.apache.commons.logging.LogFactory was unintentionally initialized at build time. #58

@gswy

Description

@gswy

如题,SpringBoot 3.x 在打包Native报错:

Error: Classes that should be initialized at run time got initialized during image building:
Error: Classes that should be initialized at run time got initialized during image building:
 org.apache.commons.logging.LogFactory was unintentionally initialized at build time. To see why org.apache.commons.logging.LogFactory got initialized use --trace-class-initialization=org.apache.commons.logging.LogFactory
org.apache.commons.logging.LogFactoryService was unintentionally initialized at build time. To see why org.apache.commons.logging.LogFactoryService got initialized use --trace-class-initialization=org.apache.commons.logging.LogFactoryService
To see how the classes got initialized, use --trace-class-initialization=org.apache.commons.logging.LogFactory,org.apache.commons.logging.LogFactoryService

经过maven命令排查:

./mvnw dependency:tree -Dverbose -Dincludes=commons-logging:commons-logging

得到信息:

[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------------< com.test:app >--------------------------
[INFO] Building 后台服务 0.0.1
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- dependency:3.8.1:tree (default-cli) @ app ---
[INFO] ltd.nextchat:app:jar:0.0.1
[INFO] \- com.getui.push:restful-sdk:jar:1.0.7.0:compile
[INFO]    \- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO]       \- commons-logging:commons-logging:jar:1.2:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.697 s
[INFO] Finished at: 2025-12-12T08:26:04+08:00
[INFO] ------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions