【问题标题】:Error: Could not find or load main错误:无法找到或加载主程序
【发布时间】:2017-04-26 13:23:11
【问题描述】:

我正在 Eclipse (STS) 中创建 SpringRoo 项目,并运行该项目抛出错误:无法找到或加载主类 src.main.java.com.ng.login.LogInApplication

我的项目目录


我的 Spring Roo 日志文件

jpa setup --provider HIBERNATE --database MYSQL 
entity jpa --class ~.domain.LogIn
field string --fieldName username --notNull --sizeMax 5
field string --fieldName password --notNull --sizeMax 5
repository jpa --entity ~.domain.LogIn --interface ~.respository.LogInRespository
service --entity ~.domain.LogIn --repository ~.respository.LogInRespository --interface ~.service.LogInService --class ~.service.impl.LogInServiceImpl
web mvc setup
web mvc view setup --type THYMELEAF
web mvc controller --controller ~.web.LoginController --entity ~.domain.LogIn --service ~.service.LogInService --responseType THYMELEAF
perform eclipse

请帮助我。我是 Spring Roo 的新手

【问题讨论】:

    标签: java spring spring-boot spring-roo


    【解决方案1】:

    STS 似乎没有正确加载您的项目,因为它使用 src 文件夹作为 java 包的一部分:src.main.java.com.ng。登录。.

    了解 Spring Roo 版本以及您为生成项目并将其加载到 STS 中所执行的步骤会很有趣。

    无论如何,当使用 STS Spring Roo 插件时,项目会自动创建并加载到 STS as explained in the reference guide,所以我想您已经使用文本控制台创建了项目,然后将项目导入了 STS。

    您还使用了perform eclipse 命令,这是一种调用mvn eclipse:eclipse 来生成eclipse 项目的方法。此命令已弃用,因为现在 STS 支持在不使用该实用程序的情况下加载 maven 项目。

    如果是这种情况,请尝试以下方法来解决问题:

    1. 删除 STS 中的项目。当显示确认对话框时,不要选中 Delete project contents on disk 选项。
    2. 查看您的项目根文件夹并删除任何名为 .project.settings.classpath 的文件或文件夹。
    3. 打开文件菜单并选择导入
    4. 导入对话框中,打开Maven文件夹,选择Existing maven projects选项并点击下一步
    5. 浏览到已创建项目的根文件夹。
    6. 你的项目的pom.xml文件将会出现,选择它然后点击Finish按钮。

    【讨论】:

    • @Cesar 先生,我可以按照你的步骤进行操作,但是运行这个项目会抛出这个异常。 org.apache.maven.plugin.MojoExecutionException:您需要使用 JDK 运行构建或在类路径上有 tools.jar。如果在 eclipse 构建期间发生这种情况,请确保您也在 JDK 下运行 eclipse跨度>
    • 为了能够编译 java 应用程序,您必须使用 Java JDK,它提供了 java 编译器,而不是 JRE。这就是为什么异常告诉您确保使用 Java JDK 运行 Eclipse/STS,如果使用 JRE maven 运行将无法编译项目
    • 谢谢先生,解决我的问题。先生,我在 You Tube 中观看了您与 Spring Roo 相关的视频,很好的解释
    • 谢谢!请记住验证答案是否解决了您的问题。
    • Spring roo 生成了自己的 id,但我在类中提到了自己的 id,它会抛出异常。例外是 id 已在 test_Roo.aj 中定义
    猜你喜欢
    • 2016-06-12
    • 2016-03-16
    • 2016-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多