2017-06-04 46 views
0

創建表我有問題,在數據庫中創建表,當啓動應用程序,我得到這個例外Heroku的不PostgreSQL的

There was an unexpected error (type=Internal Server Error, status=500). 
could not extract ResultSet; SQL [n/a]; nested exception is 
org.hibernate.exception.SQLGrammarException: could not extract ResultSet 

之後,我檢查我的數據庫Heroku的PG:信息,看到我沒有表

Plan:  Hobby-dev 
Status:  Available 
Connections: 10/20 
PG Version: 9.6.2 
Created:  2017-05-31 10:35 UTC 
Data Size: 7.2 MB 
Tables:  0 
Rows:  0/10000 (In compliance) 
Fork/Follow: Unsupported 
Rollback: Unsupported 

我使用Spring引導和我application.properties

spring.datasource.url=${JDBC_DATABASE_URL} 
spring.datasource.username=${JDBC_DATABASE_USERNAME} 
spring.datasource.password=${JDBC_DATABASE_PASSWORD} 
spring.datasource.driverClassName=org.postgresql.Driver  
spring.datasource.maxActive=10 
spring.datasource.maxIdle=5 
spring.datasource.minIdle=2 
spring.datasource.initialSize=5 
spring.datasource.removeAbandoned=true 
spring.jpa.show-sql=false 
spring.jpa.generate-ddl=true 
spring.jpa.hibernate.ddl-auto=create 
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 

我使用ORM,和我的課看起來像一個:

@Entity 
@Table(name = "MINUSUSER") 
public class User extends AbstractBaseEntity { 

    @NotNull 
    @Column(name = "USERNAME", unique = true) 
    private String username; 

    @NotNull 
    @Column(name = "PASSWORD") 
    private String password; 

    @NotNull 
    @Column(name = "EMAIL", unique = true) 
    private String email; 

    @NotNull 
    @Column(name = "FIRSTNAME") 
    private String firstname; 

    @NotNull 
    @Column(name = "LASTNAME") 
    private String lastname; 

    @Column(name = "IMAGE") 
    private String image; 

    //get 
    //set 
} 

的pom.xml

<packaging>jar</packaging> 

<dependency> 
    <groupId>org.postgresql</groupId> 
    <artifactId>postgresql</artifactId> 
    <version>9.4.1208</version> 
</dependency> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
     <plugin> 
      <groupId>com.heroku.sdk</groupId> 
      <artifactId>heroku-maven-plugin</artifactId> 
      <version>1.0.0</version> 
     </plugin> 
    </plugins> 
</build> 

當我運行本地應用程序的一切工作正常。

+0

我不確定它爲什麼不起作用,但'spring.jpa.hibernate.ddl-auto = create'肯定不推薦用於生產。您應該使用像Liquibase這樣的遷移:https://devcenter.heroku.com/articles/running-database-migrations-for-java-apps – codefinger

回答

-1

我在eclipse中用數據庫參數啓動應用程序並創建表格,之後我將應用程序部署到heroku。