Heroku不会在postgresql上创建表

时间:2017-06-04 21:25:13

标签: java spring postgresql heroku spring-boot

我在数据库上创建表时遇到问题,启动应用程序时我遇到此异常

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:info检查我的数据库,看看我没有桌子

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 Boot和我的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> 

当我在本地运行app时一切正常。

1 个答案:

答案 0 :(得分:-1)

我在eclipse中使用数据库参数启动应用程序并创建表,之后我将我的应用程序部署到heroku。