0

i was doing a small project for library management. so, for that i have started with this simple thing to add details and fetching them. i am not getting table created when i use h2 database. here is my code. could someone fix it.

import javax.persistence.Entity;           
import javax.persistence.Id;        
import javax.persistence.Table;           
@Table(name ="library")
    @Entity          
    public class Book      {
    @Id
    private int id;      
    private String author;         
    private String title;          

    public int getId()        {    
        return id;         
    }
               public void setId(int id)   {
        this.id = id;        
    }                  
           public String getAuthor()   {          
        return author; 
    }
    public void setAuthor(String author)  {    
        this.author = author;        
    }       
    public String getTitle() {            
        return title;                      
    }        
    public void setTitle(String title) {      
        this.title = title;           
    }      
    @Override
    public String toString() {          
        return "Book [id=" + id + ", author=" + author + ", title=" + title + "]";      
    }
eisbehr
  • 12,243
  • 7
  • 38
  • 63
mounika
  • 97
  • 2
  • 5
  • 14
  • 2
    add more details. What version of spring-boot are you using and show also configuration in `application.properties` – bilak Aug 07 '18 at 07:10

1 Answers1

0

Make sure your application.properties file has below properties.

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:~/dbname
Alien
  • 15,141
  • 6
  • 37
  • 57
  • yeah, i have the same thing in my application.properties. even though i am not getting – mounika Aug 07 '18 at 08:47
  • please refer this https://stackoverflow.com/questions/45302132/h2-not-creating-updating-table-in-my-spring-boot-app-somethings-wrong-with-my – Alien Aug 07 '18 at 08:51