Hibernate does not automatically create table in mysql

1

I'm studying Spring with a bit of Hibernate, where I stopped in a situation I can not get through.

I've set up the hibernate code for creating tables in the database, but when I run the application it does not create.

My template class:

@Entity

@Table(name="cliente")

public class Cliente {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    private String nome;


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }
}

My properties:

server.port=${port:8080}
spring.datasource.url=jdbc:mysql://localhost:3306/clientesdb
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.jpa.hibernate.ddl-auto = update

MySQL without a password.

Am I doing something wrong?

    
asked by anonymous 17.04.2017 / 21:15

2 answers

0

I decided to put the annotation to scan the package of my entity in my Application class:

@EntityScan (basePackages = {"br.com.springboot.model"})

    
18.04.2017 / 21:35
0

Failed to add dialect to your properties

spring.datasource.url=jdbc:mysql://localhost:3306/clientesdb​;create=true
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.jpa.hibernate.ddl-auto=update

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=true

I also put show-sql if not right, post the sql that is being generated

Another important point is also to check the import of your entity, make sure your import is javax.persistence.Entity

    
18.04.2017 / 01:10