You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IntelliJ IDEA插件开发遭遇ClassNotFoundException求助

IntelliJ IDEA插件开发:HelloWorldAction类加载失败(ClassNotFoundException)

开发IntelliJ IDEA插件时触发ClassNotFoundException,无法加载HelloWorldAction类,检查类路径、插件描述文件及加载状态后问题仍未解决,寻求解决方案。

关键信息

  • IntelliJ IDEA版本:2022.2.5
  • JDK版本:17.0.6

异常信息

Caused by: java.lang.ClassNotFoundException: com.example.plugdemo.HelloWorldAction

插件配置文件(plugin.xml)

<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin>
    <id>com.example.plugdemo</id>
    <name>Plugdemo</name>
    <vendor email="support@yourcompany.com" url="https://www.yourcompany.com">YourCompany</vendor>
    <description><![CDATA[
    Enter short description for your plugin here.<br>
    <em>most HTML tags may be used</em>
  ]]></description>
    <depends>com.intellij.modules.platform</depends>
    <extensions defaultExtensionNs="com.intellij"></extensions>
    <actions>
        <action id="demo.hello.world" class="com.example.plugdemo.HelloWorldAction" text="HelloWorld"
                description="the HelloWorld Action">
            <add-to-group group-id="HelpMenu" anchor="first"/>
        </action>
    </actions>
</idea-plugin>

HelloWorldAction类代码

package com.example.plugdemo;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.psi.PsiFile;

public class HelloWorldAction extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent e) {
        Project project = e.getData(PlatformDataKeys.PROJECT);
        PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE);
        String classPath = psiFile.getVirtualFile().getPath();
        String title = "Hello World!";
        Messages.showMessageDialog(project, classPath, title, Messages.getInformationIcon());
    }
}

已尝试方案

  • 重建项目
  • 检查插件描述文件中的类路径配置
  • 确认插件在IDEA中已正确加载

请问是否有开发者遇到过类似问题?或者有其他排查/解决方向?如需更多信息(如项目结构截图)可补充提供。感谢帮助!🙏

内容的提问来源于stack exchange,提问作者red-dragon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 19:16:10