XXX is in unnamed module of loader ‘app‘ 解决方案

今天在写一个很简单的Demo的时候,遇到了这个问题is in unnamed module of loader 'app'。

先说解决方法:若pom中有引入 spring-boot-devtools ,将其注释后重启。

以下是我自己遇到的代码情况

    @RequestMapping("/get")
    public R<List<DiaryRespVO>> getDiary() {
        List<Diary> list = diaryService.list();
        System.out.println(list);
        Diary diary = list.get(0);
        System.out.println(diary);
        return R.ok(null);
    }
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table("diary")
public class Diary {
    @Id(keyType = KeyType.Auto)
    private Long id;

    private String content;

    @Column(typeHandler = JacksonTypeHandler.class)
    private List<String> pictureList;

    @Column(isLogicDelete = true)
    private Boolean delFlag;

    @Column(onInsertValue = "now()")
    private Date createTime;

    @Column(onUpdateValue = "now()", onInsertValue = "now()")
    private Date updateTime;

    @Column(version = true)
    private Integer version;
}

uninstall silentlyCommand Line: abort vfprintf -XX:ErrorFile=C:\Users\Administrator\java_error_in_pycharm_%p.log -XX:HeapDumpPath=C:\Users\Administrator\java_error_in_pycharm.hprof -Xms256m -Xmx1500m -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -XX:CICompilerCount=2 -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:TieredOldPercentage=100000 -ea -Dsun.io.useCanonCaches=false -Dsun.java2d.metal=true -Djbr.catch.SIGABRT=true -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Djdk.nio.maxCachedBufferSize=2097152 -Djava.util.zip.use.nio.for.zip.file.access=true -Dkotlinx.coroutines.debug=off -Dllm.show.ai.promotion.window.on.start=false -Djb.vmOptionsFile=C:\Program Files\JetBrains\PyCharm Community Edition 2025.1.1\bin/pycharm64.exe.vmoptions -Xbootclasspath/a:C:\Program Files\JetBrains\PyCharm Community Edition 2025.1.1/lib/nio-fs.jar -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.vendor.name=JetBrains -Didea.paths.selector=PyCharmCE2025.1 -Djna.boot.library.path=C:\Program Files\JetBrains\PyCharm Community Edition 2025.1.1/lib/jna/amd64 -Djna.nosys=true -Djna.noclasspath=true -Dpty4j.preferred.native.folder=C:\Program Files\JetBrains\PyCharm Community Edition 2025.1.1/lib/pty4j -Dio.netty.allocator.type=pooled -Dintellij.platform.runtime.repository.path=C:\Program Files\JetBrains\PyCharm Community Edition 2025.1.1/modules/module-descriptors.jar -Didea.platform.prefix=PyCharmCore -Dwsl.use.remote.agent.for.nio.filesystem=true -Djava.nio.file.spi.DefaultFileSystemProvider=com.intellij.platform.core.nio.fs.MultiRoutingFileSystemProvider -Dsplash=true -Daether.connector.resumeDownloads=false -Dcompose.swing.render.on.graphics=true --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/jdk.internal.vm=ALL-UNNAMED --add-opens=java.base/sun.net.dns=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.fs=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED --add-opens=java.desktop/com.sun.java.swing=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/java.awt.image=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.awt.datatransfer=ALL-UNNAMED --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens=java.desktop/sun.font=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.desktop/sun.swing=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-opens=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED -Dide.native.launcher=true -Djcef.sandbox.ptr=000001C3FF477220 -Djcef.sandbox.cefVersion=122.1.9+gd14e051+chromium-122.0.6261.94 com.intellij.idea.Main Host: Intel(R) Core(TM) i9-14900K, 32 cores, 95G, Windows 11 , 64 bit Build 26100 (10.0.26100.3912) Time: Wed May 14 10:42:32 2025 Windows 11 , 64 bit Build 26100 (10.0.26100.3912) elapsed time: 10.140251 seconds (0d 0h 0m 10s)
05-15
Abnormal build process termination: "D:\Program Files\IDEA\IntelliJ IDEA 2025.2\jbr\bin\java.exe" -Xmx700m -Djava.awt.headless=true "-Djna.boot.library.path=D:\Program Files\IDEA\IntelliJ IDEA 2025.2/lib/jna/amd64" -Djna.nosys=true -Djna.noclasspath=true --add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -Dexternal.project.config=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\projects\lims.3c898e48\external_build_system -Dcompile.parallel=true -Drebuild.on.dependency.change=true -Didea.IntToIntBtree.page.size=32768 -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=6045328016711105503 -Djps.use.dependency.graph=true -Dfile.encoding=UTF-8 -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IntelliJIdea2025.2 "-Didea.home.path=D:/Program Files/IDEA/IntelliJ IDEA 2025.2" -Didea.config.path=C:/Users/Administrator/AppData/Roaming/JetBrains/IntelliJIdea2025.2 -Didea.plugins.path=C:/Users/Administrator/AppData/Roaming/JetBrains/IntelliJIdea2025.2/plugins -Djps.log.dir=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\log\build-log "-Djps.fallback.jdk.home=D:/Program Files/IDEA/IntelliJ IDEA 2025.2/jbr" -Djps.fallback.jdk.version=21.0.7 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/Administrator/AppData/Local/JetBrains/IntelliJIdea2025.2/compile-server/lims-shly_840d39d1/_temp_ -Djps.backward.ref.index.builder=true -Djps.backward.ref.index.builder.fs.case.sensitive=false "-Djps.kotlin.home=D:\Program Files\IDEA\IntelliJ IDEA 2025.2\plugins\Kotlin\kotlinc" -Dkotlin.incremental.compilation=true -Dkotlin.jps.dumb.mode=true -Dkotlin.jps.enable.lookups.in.dumb.mode=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=C:\Users\ADMINI~1\AppData\Local\Temp\kotlin-idea-8690595407329842680-is-running -Dkotlin.incremental.compilation=true -Dkotlin.jps.dumb.mode=true -Dkotlin.jps.enable.lookups.in.dumb.mode=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=C:\Users\ADMINI~1\AppData\Local\Temp\kotlin-idea-8690595407329842680-is-running -Dide.compiler.maven.path.to.home=E:\maven\apache-maven-3.6.3-bin\repository -Dide.propagate.context=false -Dintellij.platform.log.sync=true -classpath "D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/jps-launcher.jar" org.jetbrains.jps.cmdline.Launcher "D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/jps-builders.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/jps-builders-6.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/jps-javac-extension.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/util-8.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/util_rt.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/platform-loader.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/annotations.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/trove.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/kotlin-metadata.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/protobuf.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/rt/netty-jps.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/jps-model.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/javac2.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/forms_rt.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/util.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/lib-client.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/aether-dependency-resolver.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/maven-resolver-connector-basic.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/maven-resolver-transport-file.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/maven-resolver-transport-http.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/idea_rt.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/JavaEE/lib/jasper-v2-rt.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/lib/util-8.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/javaFX/lib/javaFX-jps.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/javaFX/lib/javaFX-common.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/eclipse/lib/eclipse-jps.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/eclipse/lib/eclipse-common.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/JavaEE/lib/jps/javaee-jps.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/platform-langInjection/lib/java-langInjection-jps.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/Groovy/lib/groovy-jps.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/Groovy/lib/groovy-constants-rt.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/maven/lib/maven-jps.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/gradle-java/lib/gradle-jps.jar;D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/JPA/lib/jps/javaee-jpa-jps.jar" org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 49955 dc1fbe86-22cc-4b93-a3a1-50c9392808ed C:/Users/Administrator/AppData/Local/JetBrains/IntelliJIdea2025.2/compile-server Be careful, logger will be shut down earlier than application: Unable to make field private static java.util.IdentityHashMap java.lang.ApplicationShutdownHooks.hooks accessible: module java.base does not "opens java.lang" to unnamed module @682a0b20 Build process started. Classpath: D:/Program Files/IDEA/IntelliJ IDEA 2025.2/plugins/java/lib/jps-launcher.jar JAVAC_PROCESS[STDOUT]: # JAVAC_PROCESS[STDOUT]: # There is insufficient memory for the Java Runtime Environment to continue. JAVAC_PROCESS[STDOUT]: # Native memory allocation (malloc) failed to allocate 375328 bytes for Chunk::new JAVAC_PROCESS[STDOUT]: # An error report file with more information is saved as: JAVAC_PROCESS[STDOUT]: # C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\compile-server\hs_err_pid22588.log JAVAC_PROCESS[STDOUT]: [thread 21232 also had an error] JAVAC_PROCESS[STDOUT]: # JAVAC_PROCESS[STDOUT]: # There is insufficient memory for the Java Runtime Environment to continue. JAVAC_PROCESS[STDOUT]: # Native memory allocation (malloc) failed to allocate 32744 bytes for ChunkPool::allocate JAVAC_PROCESS[STDOUT]: # An error report file with more information is saved as: JAVAC_PROCESS[STDOUT]: # C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\compile-server\hs_err_pid27164.log JAVAC_PROCESS[STDOUT]: [thread 2064 also had an error] JAVAC_PROCESS[STDOUT]: # JAVAC_PROCESS[STDOUT]: # Compiler replay data is saved as: JAVAC_PROCESS[STDOUT]: # C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\compile-server\replay_pid22588.log 2025-08-26 13:27:42,498 [ 7595] WARN - io.netty.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. java.net.SocketException: Connection reset at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401) at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434) at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:255) at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.handle(AbstractNioChannel.java:444) at io.netty.channel.nio.NioIoHandler$DefaultNioRegistration.handle(NioIoHandler.java:386) at io.netty.channel.nio.NioIoHandler.processSelectedKey(NioIoHandler.java:585) at io.netty.channel.nio.NioIoHandler.processSelectedKeysPlain(NioIoHandler.java:530) at io.netty.channel.nio.NioIoHandler.processSelectedKeys(NioIoHandler.java:503) at io.netty.channel.nio.NioIoHandler.run(NioIoHandler.java:478) at io.netty.channel.SingleThreadIoEventLoop.runIo(SingleThreadIoEventLoop.java:203) at io.netty.channel.SingleThreadIoEventLoop.run(SingleThreadIoEventLoop.java:174) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:1123) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583) JAVAC_PROCESS[STDOUT]: # JAVAC_PROCESS[STDOUT]: # There is insufficient memory for the Java Runtime Environment to continue. JAVAC_PROCESS[STDOUT]: # Native memory allocation (malloc) failed to allocate 590480 bytes for Chunk::new JAVAC_PROCESS[STDOUT]: # An error report file with more information is saved as: JAVAC_PROCESS[STDOUT]: # C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\compile-server\hs_err_pid18280.log JAVAC_PROCESS[STDOUT]: # JAVAC_PROCESS[STDOUT]: # Compiler replay data is saved as: JAVAC_PROCESS[STDOUT]: # C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\compile-server\replay_pid27164.log # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 319696 bytes. Error detail: Chunk::new # An error report file with more information is saved as: # C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\compile-server\hs_err_pid25952.log 2025-08-26 13:27:42,520 [ 7617] WARN - io.netty.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. java.net.SocketException: Connection reset at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401) at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434) at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:255) at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.handle(AbstractNioChannel.java:444) at io.netty.channel.nio.NioIoHandler$DefaultNioRegistration.handle(NioIoHandler.java:386) at io.netty.channel.nio.NioIoHandler.processSelectedKey(NioIoHandler.java:585) at io.netty.channel.nio.NioIoHandler.processSelectedKeysPlain(NioIoHandler.java:530) at io.netty.channel.nio.NioIoHandler.processSelectedKeys(NioIoHandler.java:503) at io.netty.channel.nio.NioIoHandler.run(NioIoHandler.java:478) at io.netty.channel.SingleThreadIoEventLoop.runIo(SingleThreadIoEventLoop.java:203) at io.netty.channel.SingleThreadIoEventLoop.run(SingleThreadIoEventLoop.java:174) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:1123) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583) JAVAC_PROCESS[STDOUT]: # JAVAC_PROCESS[STDOUT]: # Compiler replay data is saved as: JAVAC_PROCESS[STDOUT]: # C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\compile-server\replay_pid18280.log 2025-08-26 13:27:42,593 [ 7690] WARN - io.netty.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. java.net.SocketException: Connection reset at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401) at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434) at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:255) at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.handle(AbstractNioChannel.java:444) at io.netty.channel.nio.NioIoHandler$DefaultNioRegistration.handle(NioIoHandler.java:386) at io.netty.channel.nio.NioIoHandler.processSelectedKey(NioIoHandler.java:585) at io.netty.channel.nio.NioIoHandler.processSelectedKeysPlain(NioIoHandler.java:530) at io.netty.channel.nio.NioIoHandler.processSelectedKeys(NioIoHandler.java:503) at io.netty.channel.nio.NioIoHandler.run(NioIoHandler.java:478) at io.netty.channel.SingleThreadIoEventLoop.runIo(SingleThreadIoEventLoop.java:203) at io.netty.channel.SingleThreadIoEventLoop.run(SingleThreadIoEventLoop.java:174) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:1123) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583) # # Compiler replay data is saved as: # C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2025.2\compile-server\replay_pid25952.log 这是什么报错
最新发布
08-27
Java中,`is in unnamed module of loader 'app'` 类似错误通常与类加载机制或模块系统(Java 9+ 的模块化系统)有关。这种错误信息表明两个类虽然属于相同的类名,但由于加载它们的类加载器不同,导致在类型转换时抛出 `ClassCastException`。此类问题在使用如 FastJSON 等序列化/反序列化框架时较为常见,尤其是在涉及类加载器隔离的环境中,如 Spring Boot 的热重启机制或某些容器环境中。 当尝试将一个由 `com.alibaba.fastjson.JSONObject` 表示的对象强制转换为用户自定义的类(例如 `com.example.demo.model.ProductPrice`)时,如果 FastJSON 在反序列化过程中使用了默认的类加载器(通常是 `AppClassLoader`),而目标类是由其他类加载器(如 `RestartClassLoader`)加载的,则会发生类型转换失败的情况[^2]。 解决此类问题的方法包括: 1. **指定类加载器进行反序列化**:确保 FastJSON 使用与目标类相同类加载器进行反序列化。可以通过 `TypeReference` 和自定义 `ClassLoader` 来实现。 ```java String json = "..."; // JSON字符串 ProductPrice productPrice = JSON.parseObject(json, new TypeReference<ProductPrice>(Thread.currentThread().getContextClassLoader()) {}); ``` 2. **避免直接类型转换**:使用 FastJSON 提供的 `parseObject` 方法将 JSON 字符串直接解析为目标类的实例,而不是先解析为 `JSONObject` 再转换。 ```java ProductPrice productPrice = JSON.parseObject(jsonString, ProductPrice.class); ``` 3. **配置 FastJSON 的反序列化策略**:通过配置 FastJSON 的反序列化特性,如启用 `SupportNonPublicField` 或 `DisableFieldSmartMatch`,以适应特定的类结构和访问控制需求。 4. **检查依赖版本兼容性**:确保项目中使用的 FastJSON 版本与运行时环境及其他库的版本兼容,避免因版本差异导致的类加载问题。 5. **优化类加载器配置**:在某些框架(如 Spring Boot)中,可以调整类加载器的行为,例如禁用热重启功能或调整类加载策略,以减少类加载器之间的冲突。 在处理排序操作时,若涉及的对象类型存在上述类加载问题,也可能间接导致排序失败。因此,在执行排序前,确保所有参与排序的对象都能正确加载且类型一致是至关重要的。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值