简体   繁体   English

转换为maven后出现错误:找不到或加载主类

[英]After converting to maven getting error : Could not find or load main class

Suddenly I got an error when converting to maven. 转换为Maven时突然出现错误。 I create a simple java project, run main class, get results. 我创建一个简单的java项目,运行主类,获取结果。 After converting to maven - I got error : Could not find or load main class. 转换为maven后-我收到错误消息:无法找到或加载主类。

I tried deleting eclipse and its folder and download it again and get the same error. 我尝试删除eclipse及其文件夹,然后再次下载并得到相同的错误。 Do you know what can be the problem? 您知道可能是什么问题吗?

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
            System.out.println("Hello World");
    }

}

What I have noticed is that when I covert the project to maven, the maven did not create 'Maven Managed Dependencies'. 我注意到的是,当我向Maven隐瞒项目时,Maven并未创建“ Maven托管依赖项”。 Moreover I click on configure build path --> Add library --> Maven Managed Dependencies . 此外,我单击配置构建路径->添加库-> Maven托管依赖项。 and it does not add the folder. 并且它不添加文件夹。

应用树

Try this: 尝试这个:

Right click on the project > Properties > Maven > Java EE Integration > Uncheck the option "Maven Archiver generates files under the build directory". 右键单击项目>属性> Maven> Java EE集成>取消选中“ Maven Archiver在构建目录下生成文件”选项。

This should fix it. 这应该解决它。 If it doesn't try Maven clean and install again. 如果不尝试,请尝试清洁Maven并重新安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM