Springboot Automatically generate database tables

Source: Internet
Author: User

@Entity

@Table (name= "T_book")//table name name is not necessarily useful

public class Book {


@Id//Id of the table

@GeneratedValue//Self-increment property

Private Integer ID;

@Column (length=100)//string Auto-corresponding string

private String name;

@Column (LENGTH=50)

Private String author;


The corresponding table is generated according to the comments


But I got a bug in the process of generating the tag because I didn't follow the spec.

Must be the same as the Startup Class (Xxxxapplication) package name to be scanned


Pom.xml introduction of database-driven and JPA-dependent

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-data-jpa</artifactId>

</dependency>


This article is from the "11854647" blog, please be sure to keep this source http://11864647.blog.51cto.com/11854647/1965819

Springboot automatically generate database tables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.