为什么我无法在H2模式中找到我的表/如何验证我的Spring Boot应用程序正在使用哪个H2模式? [英] Why I can't find my tables in H2 schema / How can I validate which H2 schema my Spring boot app is working with?

查看:135
本文介绍了为什么我无法在H2模式中找到我的表/如何验证我的Spring Boot应用程序正在使用哪个H2模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个Spring Boot应用程序

I'm running a spring boot app

除了maven之外,h2没有其他设置

didn't have any setting for h2 other than maven

当我连接到h2控制台时,我可以看到应该为两个实体创建的表

when i'm connecting to the h2 console i can see the tables that were supposed to be created for two entities

我连接了JDBC URL: jdbc:h2:mem:testdb (应该是默认设置)

i connected with the JDBC URL: jdbc:h2:mem:testdb (which is supposed to be the default)

是否有办法确保H2当前正在运行哪些模式/或H2的某些日志文件?

Is there a way to make sure what schemas is H2 currently running/ or some log file for H2 ?

在我的application.properties中,我有这个:

in my application.properties i have this:

spring.h2.console.enabled=true
spring.h2.console.path=/h2

我在登录时看到某个地方H2会初始化自身,但是我正在观看的演示中已经采取了这些确切步骤,所以不确定情况是否如此.

I read somewhere that H2 initializing itself upon login, but a demo i was watching these were the exact steps taken , so not sure that is the case.

这些是H @控制台中的设置:

these are the settings in the H@ console:

推荐答案

我实际上一直看到正确的架构

I actually saw the right schema all along

我认为我没有看到正确的架构的原因是-我期望看到的JPA实体不存在.

The reason I thought I wasn't seeing the right schema was - the JPA Entities I expected to see, were not there.

然后我发现这是因为我没有正确命名JPA实体的程序包

I then found that this was because I didn't name the package for the JPA entities correctly

我将其命名为域"(参见图片):

I named it "domain" (see pic):

我应该将其命名为com.example.domain,可以看出:

I should have named it com.example.domain as can be seen:

这是因为Spring Boot看起来在主类的包下执行@ComponentScan下",所以我必须在"domains"前面加上主类所驻留的包的名称,即com.example.

This is because Spring Boot looks is doing a @ComponentScan "under" the package with the main class , so I had to prefix the "domains" with the name of the package that the main class resides in, which is com.example.

这篇关于为什么我无法在H2模式中找到我的表/如何验证我的Spring Boot应用程序正在使用哪个H2模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆