No identifier specified for entity没有为实体指定标识符
異常
ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userServiceImpl’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userDao’ defined in com.william.dao.UserDao defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean ‘jpaMappingContext’ while setting bean property ‘mappingContext’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jpaMappingContext’: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.william.domain.User
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userServiceImpl’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userDao’ defined in com.william.dao.UserDao defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean ‘jpaMappingContext’ while setting bean property ‘mappingContext’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jpaMappingContext’: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.william.domain.User
異常原因翻譯:
ConfigServletWebServerApplicationContext:在上下文初始化期間遇到的異常——取消刷新嘗試:org.springframework.bean .factory。BeanCreationException:創建名為“userController”的bean時出錯:注入資源依賴失敗;嵌套異常是org.springframe .bean .factory。BeanCreationException:創建名為“userServiceImpl”的bean時出錯:注入資源依賴失敗;嵌套異常是org.springframe .bean .factory。BeanCreationException:創建名為“userDao”的bean時出錯,該bean在com. williams .dao中定義。UserDao定義在jpareposoriesregistrar上聲明的@ enablejparepospos存中。EnableJpaRepositoriesConfiguration:在設置bean屬性“mappingContext”時無法解析對bean“jpaMappingContext”的引用;嵌套異常是org.springframe .bean .factory。創建名為“jpaMappingContext”的bean時出錯:init方法調用失敗;嵌套異常是org.hibernate。注釋異常:沒有為實體指定標識符:com. williams .domain. user
問題根本原因:
注釋異常:沒有為實體指定標識符:com. williams .domain. user
實體類加入@Id
package com.william.domain;import javax.persistence.*;/*** @author :lijunxuan* @date :Created in 2020/5/30 12:29* @description :* @version: 1.0*/ @Table(name = "user") @Entity public class User {@Id@GeneratedValue(strategy = GenerationType.IDENTITY)private Integer id;private String username;private String password;private String name;@Overridepublic String toString() {return "User{" +"id=" + id +", username='" + username + '\'' +", password='" + password + '\'' +", name='" + name + '\'' +'}';}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String getName() {return name;}public void setName(String name) {this.name = name;} } 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的No identifier specified for entity没有为实体指定标识符的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 给笔记本电脑清灰笔记本电脑如何清灰
- 下一篇: 如何突破路由器限速路由器如何解决限速