我猜错误在这里的某个地方:
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String email;
private String hashPassword;
@Enumerated(value = EnumType.STRING)
private Role role;
}
我的数据库:
create table users
(
id int auto_increment
primary key,
name varchar(45) not null,
email varchar(45) not null,
hashPassword varchar(45) not null,
role enum ('USER', 'ADMIN') null
);
错误本身
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1236)
The following method did not exist:
javax.persistence.Table.indexes()[Ljavax/persistence/Index;
The method's class, javax.persistence.Table, is available from the following locations:
jar:file:/home/tanya/IdeaProjects/kfu-programming-java4/spring_shelter/lib/javax.persistence.jar!/javax/persistence/Table.class
jar:file:/home/tanya/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/javax/persistence/Table.class
It was loaded from the following location:
file:/home/tanya/IdeaProjects/kfu-programming-java4/spring_shelter/lib/javax.persistence.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.Table
我自己想通了,因为我有一个 unix 系统,在端口字段的 application.properties 中你需要写 8080,而我有 80 - 它在这样的系统上很忙,因此出现错误