无法找到符号 JdbcTypeCode

huangapple go评论58阅读模式
英文:

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.

&lt;dependency&gt;
  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
  &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
  &lt;version&gt;6.2.4.Final&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.hibernate.common&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-commons-annotations&lt;/artifactId&gt;
  &lt;version&gt;5.0.1.Final&lt;/version&gt;
&lt;/dependency&gt;

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-corehibernate-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 &lt;hibernate.version&gt;6.2.4.Final&lt;/hibernate.version&gt; to your &lt;properties&gt; in your pom.xml.

&lt;dependencies&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
  &lt;/dependency&gt;
&lt;/dependencies&gt;

For the version override:

&lt;properties&gt;
  &lt;java.version&gt;17&lt;/java.version&gt;
  &lt;hibernate.version&gt;6.2.4.Final&lt;/hibernate.version&gt;
&lt;/properties&gt;

huangapple
  • 本文由 发表于 2023年6月15日 17:34:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76481118.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定