简体   繁体   English

错误:找不到或加载主

[英]Error: Could not find or load main

i'm creating a SpringRoo Project in eclipse (STS), and run the project throw Error: Could not find or load main class src.main.java.com.ng.login.LogInApplication 我正在Eclipse(STS)中创建一个SpringRoo项目,并运行该项目引发错误: 无法找到或加载主类src.main.java.com.ng.login.LogInApplication

My project directory 我的项目目录

在此处输入图片说明


My Spring Roo Log File 我的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

Please Help me. 请帮我。 I'm newbie in Spring Roo. 我是Spring Roo的新手

It seems your project hasn't been loaded correctly by STS, as it is using the src folder as part of the java package: src.main.java.com.ng.login. 看来您的项目尚未通过STS正确加载,因为它使用src文件夹作为java包src.main.java.com.ng.login的一部分。 .

It would be interesting to know the Spring Roo version and the steps you have performed to generate the project and load it into the STS. 了解Spring Roo版本以及生成项目并将其加载到STS中执行的步骤将非常有趣。

Anyway, when the STS Spring Roo plugin is used the project is created and loaded in STS automatically as explained in the reference guide , so I suppose you have created the project using the text console instead and then have imported the project in STS. 无论如何,当使用STS Spring Roo插件时,将按照参考指南中的说明自动创建项目并将其加载到STS ,因此我想您已经使用文本控制台创建了该项目,然后将其导入了STS中。

Also you have used the perform eclipse command, which is a way to call mvn eclipse:eclipse to generate the eclipse project. 另外,您还使用了perform eclipse命令,这是一种调用mvn eclipse:eclipse来生成eclipse项目的方法。 This command is deprecated, as nowadays the STS has support to load maven projects without using that utility. 不推荐使用此命令,因为如今STS支持在不使用该实用程序的情况下加载Maven项目。

If that's the case, try the following to solve the problem: 如果是这种情况,请尝试以下解决问题的方法:

  1. Remove the project in STS. 在STS中删除项目。 When the confirmation dialog is shown, don't check the Delete project contents on disk option. 显示确认对话框时,请勿选中“ 删除磁盘上的项目内容”选项。
  2. Look into your project root folder and delete any file or folder called .project , .settings or .classpath . 查看您的项目根文件夹,并删除任何名为.project.settings.classpath的文件或文件夹。
  3. Open the File menu and select Import 打开文件菜单,然后选择导入
  4. In the Import dialog, open the Maven folder, select the Existing maven projects option and click Next 在“ 导入”对话框中,打开Maven文件夹,选择“ 现有maven项目”选项,然后单击“ 下一步”。
  5. Browse to the root folder of the created project. 浏览到创建的项目的根文件夹。
  6. The pom.xml file of your project will appear, select it and then click the Finish button. 您的项目的pom.xml文件将出现,选择它,然后单击“ 完成”按钮。

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

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