且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我无法在H2模式中找到我的表/如何验证我的Spring Boot应用程序正在使用哪个H2模式?

更新时间:2023-10-19 08:26:46

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

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.