英文:
Cannot find symbol JdbcTypeCode
问题
我的Springboot Maven应用在构建过程中出现了“找不到符号错误”。
#13 552.4 [ERROR] /build/src/main/java/com/../Employee.java:[26,32] error: cannot find symbol
#13 552.4 [ERROR] symbol: class JdbcTypeCode
#13 552.4 [ERROR] location: package org.hibernate.annotations
#13 552.4 [ERROR] /build/src/main/java/com/../Employee.java:[27,25] error: cannot find symbol
#13 552.4 [ERROR] symbol: class SqlTypes
#13 552.4 [ERROR] location: package org.hibernate.type
我已经在我的pom.xml中添加了以下内容,但仍然出现上述错误。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.2.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.1.Final</version>
</dependency>
我在这里漏掉了什么?
不确定如何修复这些问题。已经搜索了Maven依赖项,但只找到了上述两个Hibernate依赖项。
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
英文:
My Springboot maven application gives "symbol not found error" during build.
#13 552.4 [ERROR] /build/src/main/java/com/../Employee.java:[26,32] error: cannot find symbol
#13 552.4 [ERROR] symbol: class JdbcTypeCode
#13 552.4 [ERROR] location: package org.hibernate.annotations
#13 552.4 [ERROR] /build/src/main/java/com/../Employee.java:[27,25] error: cannot find symbol
#13 552.4 [ERROR] symbol: class SqlTypes
#13 552.4 [ERROR] location: package org.hibernate.type
I have added following to my pom.xml still I get the above error.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.2.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.1.Final</version>
</dependency>
What am I missing here?
Not sure how to fix these. Did some search for maven dependency for following Classes the above two hibernate dependencies are only mentioned.
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
答案1
得分: 0
移除hibernate-core
和hibernate-commons-annotations
的依赖。spring-boot-starter-data-jpa
已经包含了正确的依赖项。这适用于所有的启动器,所以如果你在其中有spring-boot-starter-validation
,不要再添加hibernate-validator
。
如果你想要不同的Hibernate版本,请将<hibernate.version>6.2.4.Final</hibernate.version>
添加到你的pom.xml
中的<properties>
部分。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
对于版本覆盖:
<properties>
<java.version>17</java.version>
<hibernate.version>6.2.4.Final</hibernate.version>
</properties>
英文:
Remove the hibernate-core
and hibernate-commons-annotations
dependencies. The spring-boot-starter-data-jpa
already pulls in the proper dependencies. This applies to all starters BTW, so if you have spring-boot-starter-validation
in there and hibernate-validator
don't do that.
If you want a different hibernate version add <hibernate.version>6.2.4.Final</hibernate.version>
to your <properties>
in your pom.xml
.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
For the version override:
<properties>
<java.version>17</java.version>
<hibernate.version>6.2.4.Final</hibernate.version>
</properties>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论