为什么我的 Spring Boot 应用程序不生成表

问题描述 投票:0回答:1

您好,为什么定义的语法,包括用必要的JPA注释注释的Java实体类“Application”,以及“application.properties”文件中指定的数据库配置,没有成功在指定的PostgreSQL数据库中创建相应的表JDBC URL?

型号:

@Getter
@Setter
@Entity
@AllArgsConstructor
@NoArgsConstructor
public class Application {
    @Id
    @Column(name = "id", nullable = false)
    private Long id;

    @Column(name = "clientId", nullable = false)
    private String clientId;

    @Column(name = "url", nullable = false)
    private String url;
    @Column(name = "name", nullable = false)
    private String name;
    @Column(name = "hostname", nullable = false)
    private String hostname;

    @Column(name = "cssurl", nullable = true)
    private String cssurl;

}

应用程序属性:

# DataSource settings
spring.datasource.url=jdbc:postgresql://localhost:5432/ishotit
spring.datasource.username=ishotit
spring.datasource.password=apipassword

# JPA/Hibernate settings
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create

# Debug SQL and Hibernate types
# logging.level.org.hibernate.SQL=DEBUG
# logging.level.org.hibernate.type=TRACE

# RabbitMQ settings
rabbitmq.username=guest
rabbitmq.password=guest
rabbitmq.host=localhost
rabbitmq.port=5672
rabbitmq.queueFile=queueFile
rabbitmq.topic=topic
java spring spring-boot hibernate spring-data-jpa
1个回答
0
投票

原因之一可能是封装结构。默认情况下,只有当实体类与主应用程序类(或其子包)位于同一包中时才会找到。否则,您需要将

@EnityScan
注解添加到主应用程序类中。

© www.soinside.com 2019 - 2024. All rights reserved.