org.apache.commons.logging.LogFactory 在构建时无意中初始化了

问题描述 投票:0回答:1

我正在使用 GraalVM 21、JDK 21、Ubuntu 22.04 LTS

# On Ubuntu 22.04 Operating system (WSL 2)
chmod +x mvnw 
./mvnw -Pnative spring-boot:build-image

日志

[INFO]     [creator]      - '-H:+StaticExecutableWithDynamicLibC' (origin(s): command line)
[INFO]     [creator]      - '-H:ResourceConfigurationResources' (origin(s): 'META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/native-image.properties' in 'file:///workspace/BOOT-INF/lib/tomcat-embed-core-10.1.17.jar', 'META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-websocket/native-image.properties' in 'file:///workspace/BOOT-INF/lib/tomcat-embed-websocket-10.1.17.jar', 'META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-el/native-image.properties' in 'file:///workspace/BOOT-INF/lib/tomcat-embed-el-10.1.17.jar')
[INFO]     [creator]      - '-H:ReflectionConfigurationResources' (origin(s): 'META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/native-image.properties' in 'file:///workspace/BOOT-INF/lib/tomcat-embed-core-10.1.17.jar', 'META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-websocket/native-image.properties' in 'file:///workspace/BOOT-INF/lib/tomcat-embed-websocket-10.1.17.jar', 'META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-el/native-image.properties' in 'file:///workspace/BOOT-INF/lib/tomcat-embed-el-10.1.17.jar')
[INFO]     [creator]     --------------------------------------------------------------------------------
[INFO]     [creator]     Build resources:
[INFO]     [creator]      - 8.49GB of memory (68.5% of 12.40GB system memory, determined at start)
[INFO]     [creator]      - 4 thread(s) (100.0% of 4 available processor(s), determined at start)
[INFO]     [creator]     Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts
[INFO]     [creator]     Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts
[INFO]     [creator]     SLF4J: No SLF4J providers were found.
[INFO]     [creator]     SLF4J: Defaulting to no-operation (NOP) logger implementation
[INFO]     [creator]     SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
[INFO]     [creator]     [2/8] Performing analysis...  []                                (58.2s @ 1.13GB)
[INFO]     [creator]        10,656 reachable types   (85.8% of   12,415 total)
[INFO]     [creator]        16,663 reachable fields  (61.0% of   27,318 total)
[INFO]     [creator]        50,655 reachable methods (59.2% of   85,634 total)
[INFO]     [creator]         3,407 types,   314 fields, and 2,521 methods registered for reflection
[INFO]     [creator]
[INFO]     [creator]     Error: Classes that should be initialized at run time got initialized during image building:
[INFO]     [creator]      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
[INFO]     [creator]     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
[INFO]     [creator]     To see how the classes got initialized, use --trace-class-initialization=org.apache.commons.logging.LogFactory,org.apache.commons.logging.LogFactoryService
[INFO]     [creator]     --------------------------------------------------------------------------------
[INFO]     [creator]         9.0s (12.6% of total time) in 99 GCs | Peak RSS: 2.49GB | CPU load: 3.71
[INFO]     [creator]     ================================================================================
[INFO]     [creator]     Finished generating '....MasterdataserviceApplication' in 1m 10s.
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to contribute native-image layer
[INFO]     [creator]     error running build
[INFO]     [creator]     exit status 1
[INFO]     [creator]     ERROR: failed to build: exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:35 min
[INFO] Finished at: 2024-01-08T16:10:40+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.2.1:build-image (default-cli) on project masterdataservice: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.2.1:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

如何解决?

java spring spring-boot maven spring-native
1个回答
0
投票

使用解决方案https://github.com/Consensys/teku/issues/7486#issuecomment-1720438947,使用log4j-over-slf4j依赖

© www.soinside.com 2019 - 2024. All rights reserved.