質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

Q&A

0回答

306閲覧

JPAで一部のテーブルが自動生成されない。

vemic

総合スコア1

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

0グッド

0クリップ

投稿2022/11/09 15:00

前提

  • SpringBootでJPAを使用してテーブルを自動生成しています。

yml

1 jpa: 2 database-platform: org.hibernate.dialect.PostgreSQLDialect 3 hibernate: 4 ddl-auto: update
  • @EntityScan の設定はしており、他のテーブルは自動生成されるのですが、一部パッケージ配下のテーブルが自動生成されません。

該当のソースコード

java

1package example; 2 3import javax.persistence.Column; 4import javax.persistence.Entity; 5import javax.persistence.Id; 6import javax.persistence.Table; 7 8import lombok.Data; 9 10@Entity 11@Table(name = "m_role") 12@Data 13public class MRole { 14 @Id 15 @Column 16 String roleId; 17 @Column 18 String roleName; 19} 20

試したこと

別のパッケージのクラスに対応するテーブルは自動生成されます。

java

1package example; 2 3import javax.persistence.Column; 4import javax.persistence.Entity; 5import javax.persistence.Id; 6import javax.persistence.Table; 7 8import lombok.Data; 9 10@Entity 11@Table(name = "m_project") 12@Data 13public class MProject { 14 @Id 15 @Column 16 String projectId; 17 @Column 18 String projectName; 19}

補足情報(FW/ツールのバージョンなど)

  • SpringBoot 2.4.0
  • PostgreSQL 14

build.gradle(抜粋)

gradle

1dependencies { 2 implementation 'org.springframework.boot:spring-boot-starter-actuator' 3 implementation 'org.springframework.boot:spring-boot-starter-batch' 4 implementation 'org.springframework.boot:spring-boot-starter-cache' 5 implementation 'org.springframework.boot:spring-boot-starter-groovy-templates' 6 implementation 'org.springframework.boot:spring-boot-starter-jdbc' 7 implementation 'org.springframework.boot:spring-boot-starter-mail' 8 implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' 9 implementation 'org.springframework.boot:spring-boot-starter-quartz' 10 implementation 'org.springframework.boot:spring-boot-starter-security' 11 implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 12 implementation 'org.springframework.boot:spring-boot-starter-web' 13 implementation 'org.springframework.session:spring-session-jdbc' 14 implementation 'com.h2database:h2' 15 implementation 'com.google.code.gson:gson' 16 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 17 implementation 'org.apache.commons:commons-lang3' 18 implementation 'com.google.guava:guava:30.1-jre' 19 implementation 'org.apache.poi:poi:4.1.2' 20 implementation('org.apache.poi:poi-ooxml:4.1.2') { 21 exclude group: 'stax', module: 'stax-api' 22 } 23 implementation 'commons-io:commons-io:2.8.0' 24 implementation 'org.freemarker:freemarker:2.3.30' 25 implementation 'com.vladmihalcea:hibernate-types-55:2.14.0' 26 implementation 'javax.validation:validation-api:2.0.1.Final' 27 implementation 'com.codeborne:selenide:5.17.2' 28 implementation 'commons-beanutils:commons-beanutils:1.9.4' 29 implementation 'net.sf.dozer:dozer:5.5.1' 30 annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' 31 annotationProcessor 'org.projectlombok:lombok' 32 providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' 33 testImplementation('org.springframework.boot:spring-boot-starter-test') { 34 exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 35 } 36 testImplementation 'io.projectreactor:reactor-test' 37 testImplementation 'org.springframework.batch:spring-batch-test' 38 testImplementation 'org.springframework.security:spring-security-test' 39 developmentOnly 'org.springframework.boot:spring-boot-devtools' 40 runtimeOnly 'mysql:mysql-connector-java' 41 runtimeOnly 'org.hibernate.validator:hibernate-validator:6.0.17.Final' 42 runtimeOnly 'org.glassfish:javax.el:3.0.1-b11' 43 runtimeOnly 'org.postgresql:postgresql' 44}

問題の勘所等ご教示頂きたく、何卒よろしくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問