为什么可以';我不能创建Java列表吗?

为什么可以';我不能创建Java列表吗?,java,maven,Java,Maven,我无法运行下面的代码。我得到的反馈是“找不到符号”,出现的地方是“私有列表产品”行中的字母“I” 错误消息是:[error]\Users\Filip\Dropbox\EclipseWorkspace\ProductsCarts\src\main\java\hello\Cart.java:[8,14]错误:找不到符号 我不知道这是否重要,但我正在使用Spring引导框架和Maven 怎么了?(请注意,购物车类由产品列表组成。产品代码显示在本页下方) 以下是完整的错误消息: [ERROR] \Us

我无法运行下面的代码。我得到的反馈是“找不到符号”,出现的地方是“私有列表产品”行中的字母“I”

错误消息是:[error]\Users\Filip\Dropbox\EclipseWorkspace\ProductsCarts\src\main\java\hello\Cart.java:[8,14]错误:找不到符号

我不知道这是否重要,但我正在使用Spring引导框架和Maven

怎么了?(请注意,购物车类由产品列表组成。产品代码显示在本页下方)

以下是完整的错误消息:

 [ERROR] \Users\Filip\Dropbox\EclipseWorkspace\ProductsCarts\src\main\java\hello\Cart.java:[8,14] error: cannot find symbol
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project gs-handling-form-submission: Compilation failure
[ERROR] \Users\Filip\Dropbox\EclipseWorkspace\ProductsCarts\src\main\java\hello\Cart.java:[8,14] error: cannot find symbol
[ERROR] -> [Help 1]
 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
 [ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
C:\Users\Filip\Dropbox\EclipseWorkspace\ProductsCarts>

您正在混合目录布局。Maven将源代码放入
src/main/java
,而不仅仅是
src
。您的包声明认为您只是将代码放入
src
。删除额外的组件,您可能不会使用m2eclipse来管理Eclipse构建;如果不是,请将项目作为Maven项目安装并导入

只需创建示例java项目并安装“m2eclipse”插件来管理eclipse构建。然后右键单击您的项目转到配置并单击convert to maven选项,然后您的项目被转换为maven,在您的项目目录根文件夹pom.xml文件被生成。并检查您的包文件夹,如src/main/java和src/test/java等。然后在此位置创建包src/main/java并创建java文件。如果您需要为您的项目添加任何jar文件,只需更新它包含的pom.xml文件

<groupId>....</groupid>
<artifactId>...</artifactId>
<version>....</version>`enter code here`
。。。。
...
....在此处输入代码`

是否在Spring控制器中使用了
购物车
类?您是从表单发布数据还是使用JSON?不,我甚至没有使用这两个类。我刚刚创建了它们,并希望在开始使用它们之前尝试运行应用程序。当我在命令提示符下运行应用程序时,它会失败并抛出错误消息。请用出现的错误消息更新您的问题。@Filiperikson您需要提供有关您试图做什么的更多详细信息。问题是,我有一个正常工作的spring根应用程序。为了以后的使用,我决定创建Cart和Product类。他们现在从来没有打过电话。当我尝试运行在失败之前运行的应用程序时,我得到了我知道的错误消息,粘贴到问题中。是的,你是对的。我只是把我的产品文件放错了文件夹。我想我是在看cart类时说路径是正确的。我的错。
 [ERROR] \Users\Filip\Dropbox\EclipseWorkspace\ProductsCarts\src\main\java\hello\Cart.java:[8,14] error: cannot find symbol
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project gs-handling-form-submission: Compilation failure
[ERROR] \Users\Filip\Dropbox\EclipseWorkspace\ProductsCarts\src\main\java\hello\Cart.java:[8,14] error: cannot find symbol
[ERROR] -> [Help 1]
 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
 [ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
C:\Users\Filip\Dropbox\EclipseWorkspace\ProductsCarts>
<groupId>....</groupid>
<artifactId>...</artifactId>
<version>....</version>`enter code here`