Je sais qu'il y a beaucoup de questions similaires ici, mais j'ai passé toute la journée sans trouver de solution.
J'utilise Hibernate 5.0.12 avec PostgreSQL 9.6.3 dans un projet Spring Boot 1.5.4.
J'ai une entité utilisateur simple :
import javax.persistence.*;
@Entity
public class User {
@Id
@GeneratedValue
@Column(nullable = false, updatable = false)
private Long id;
private String email;
private String password;
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
}
et application.properties :
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/my-db
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.hibernate.dialect=org.hibernate.dialect.PostgreSQL94Dialect
spring.hibernate.hbm2ddl.auto=create
logging.level.org.hibernate=DEBUG
Le lancement semble normal
mais la table "user" n'a pas été créée.
Avec MySQL, tout fonctionne bien. Y a-t-il un problème avec PostgreSQL ? Je suis novice en la matière et je viens de créer une base de données de ce type :
createdb -h localhost -p 5432 -U postgres my-db password *********
et, après quelques tentatives pour résoudre le problème, y a créé un schéma :
CREATE SCHEMA "my-db" AUTHORIZATION postgres;