开发者

im creating project using spring boot but i got error and not resolved yet

while running application got this error I am using MySQL 8 version and also here get dialect version 8 but its not working

I want to connect database and store my value which, I have passed package com.practice;

import org.springframework.boot.SpringApplication;
import o开发者_如何学Gorg.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import com.practice.dao.UserRepository;
import com.practice.entities.User;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
    ApplicationContext context =     SpringApplication.run(DemoApplication.class, args);
    
    UserRepository userRepository =context.getBean(UserRepository.class);
    
    User user = new User();
    user.setName("shrikant suryawanshi");
    user.setCity("Pune");
    user.setStatus("active");
    
    User user1 = userR
Repository.save(user);
    System.out.println(user1);`
    }
}

Error:

Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Entity 'com.practice.entities.User' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property)


Every entity (table in you DB) must be declared with @Entity anotation, and every Entity must have unique identifier anotated with @Id anotation, https://www.baeldung.com/jpa-entities . If error continues after fixing Entity classes add them to your question

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜