2017-06-04 45 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。