【问题标题】:spring boot and datasource generationspring boot 和数据源生成
【发布时间】:2020-02-06 21:48:06
【问题描述】:

我正在尝试在 STS 4 中的 Spring boot 中执行 ORM,因此我创建实体然后配置 application.properties,如下所示:

spring.datasource.url = jdbc:mysql://localhost:3306/basebanque

spring.datasource.username = root

spring.datasource.password = 

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.jpa.database= MYSQL

spring.jpa.show-sql = true 

spring.jpa.hibernate.ddl-auto=create

spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5Dialect

我没有获取任何数据源的问题。 控制台显示以下内容:

和:

【问题讨论】:

  • 控制台看起来不错。什么不起作用?
  • 我在 ma 数据库中找不到表(即 java 类)。
  • 你的实体是什么样子的?它们在包结构中的什么位置?
  • 实体是javabean,我把它们放在一个名为entities的包中:src/main/java
  • 您发布了日志图像而不是纯文本。请不要。

标签: spring spring-boot jpa orm


【解决方案1】:

检查扫描了哪些实体。

https://springbootdev.com/2017/11/13/what-are-the-uses-of-entityscan-and-enablejparepositories-annotations/amp/

默认情况下,Spring Boot 会启用实体扫描,并在 @SpringBootApplication 所在的包(及其子包)中查找。如果您的配置在另一个包中包含实体,请使用 @EntityScan。

【讨论】:

    猜你喜欢
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-21
    • 1970-01-01
    • 2017-05-28
    • 2017-11-13
    相关资源
    最近更新 更多