java - 项目找不到类
问题描述
我正在编写一个 Java 项目来了解 JPA 和 JDBC。eclipse 中的项目被称为WSShop
& 访问另一个名为 的 eclipse 项目JPAUtilities
,其中包含一个名为的类,该类JPAUtils
使用一个EntityManager
类。
我的问题是,虽然使用的项目没有问题,但JPAUtilities
使用EntityManager
的WSShop
项目JPAUtilities
发现问题EntityManager
并给出错误消息
Description Resource Path Location Type
The project was not built since its build path is incomplete. Cannot find the class file for javax.persistence.EntityManager. Fix the build path then try building this project WSShop Unknown Java Problem
The type javax.persistence.EntityManager cannot be resolved. It is indirectly referenced from required .class files JPAUserDAO.java /WSShop/src/main/java/com/example/demo line 35 Java Problem
以下是项目和子项目的设置:
我将java.persistence
JAR 添加到WSShop
项目中,但仍然得到相同的错误:
但是JPAUtilities
被 使用WSShop
,但JPAUtilities
没有任何问题(WSShop
在此处关闭):
我究竟做错了什么?
谢谢您的帮助!
编辑:
我检查了pom.xml
& 将错误减少到三个。现在,EntityManager
不再是问题了。POM 文件包含以下几行:
<dependency>
<groupId>org.springframework.boot.autoconfigure</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>2.1.7.RELEASE</version>
</dependency>
存在…\.m2\repository\org\springframework\boot\spring-boot\2.1.7.RELEASE
带有spring-boot-2.1.7.RELEASE
可执行 Jar 文件的目录。我改变了项目的配置如下
…现在是错误和警告
解决方案
推荐阅读
- python - 以特定方式多次连接两个矩阵
- docker - Grafana 仪表板中的 Kubernetes pod 使用 Current、Requested、Limit 和 Cache 显示内存使用情况。缓存表示什么?
- android - 如何修复“预期的 NDK STL 共享对象文件”?
- qt - .pri 文件在 qt creator 中显示为 .pro 文件
- python-3.x - 为什么在 pandas 行中使用列表作为值允许我即时更新?
- r - 在分组后在 R 中使用 Levene 测试时出错 [错误:不是数字变量]
- java - 具有不同对象的反序列化 json 数组 - jackson/spring
- google-apps-script - Google Apps 脚本组合图表在 x 轴上重复相同的值
- mysql - 更新查询 - @
- c# - 如何从服务“内部”的代码访问托管在 IIS 中的 WCF 服务的 web.config