简体   繁体   English

对于 Jhipster 生成的项目,H2 表未显示在 IntelliJ 中

[英]H2 tables not showing up in IntelliJ for Jhipster generated project

So I generated a new Spring boot application using jhipster.所以我使用 jhipster 生成了一个新的 Spring boot 应用程序。 Upon navigating to the H2 console, the following information is shown.导航到 H2 控制台后,将显示以下信息。

在此处输入图像描述

I am able to login, and I can verify tables exist.我可以登录,并且可以验证表是否存在。 在此处输入图像描述

Next, I copy the link, jdbc:h2:file:./target/h2db/db/ikdoemee and try to connect to the H2 database using IntelliJ which shows successful .接下来,我复制链接jdbc:h2:file:./target/h2db/db/ikdoemee并尝试使用显示successful的 IntelliJ 连接到 H2 数据库。 在此处输入图像描述

However, the IntelliJ database view isn't showing any tables.但是,IntelliJ 数据库视图没有显示任何表格。 在此处输入图像描述

I tried adding the following parameters to my JDBC url, but no tables show up.我尝试将以下参数添加到我的 JDBC url,但没有显示任何表格。

jdbc:h2:file:./target/h2db/db/ikdoemee;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1 ;DATABASE_TO_UPPER=false

Why am I unable to get my tables visible in IntelliJ?为什么我无法在 IntelliJ 中看到我的表格?

My.h2.server.properties is我的.h2.server.properties 是

#H2 Server Properties
0=JHipster H2 (Disk)|org.h2.Driver|jdbc\:h2\:file\:./target/h2db/db/ikdoemee|ikdoemee
webAllowOthers=true
webPort=8082
webSSL=false

EDIT: My target folder:编辑:我的目标文件夹: 在此处输入图像描述

You need to activate h2 "Automatic Mixed Mode" by changing the spring.datasource.url of the application-dev.yml file.您需要通过更改 application-dev.yml 文件的 spring.datasource.url 来激活 h2“自动混合模式”。 example URL: jdbc:h2:./target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE示例 URL: jdbc:h2:./target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE

The URL for the connection to the h2 database should look like that:连接到 h2 数据库的 URL 应该如下所示:

jdbc:h2:/home/'USERNAME'/IdeaProjects/'PROJECT'/target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE

if that doesn't work try also to delete the target folder and refresh the h2 connection如果这不起作用,还请尝试删除目标文件夹并刷新 h2 连接

The only solution that worked for me at the moment is to put the direct path to the file in Path field without extension.目前唯一对我有用的解决方案是将文件的直接路径放在 Path 字段中而不带扩展名。 After that I could see my tables in IDEA.之后我可以在 IDEA 中看到我的表格。

click to preview settings单击以预览设置

Note:笔记:

Don't forget to also add parameter AUTO_SERVER=TRUE to datasource.url , as pointed out by @Unknown_Energy .不要忘记也将参数AUTO_SERVER=TRUE添加到datasource.url ,正如@Unknown_Energy所指出的。

My apps versions:我的应用程序版本:

  • Idea 2018.3.5 UE Idea 2018.3.5 UE
  • h2 1.4.197 h2 1.4.197
  • h2 base name: demo.mv.db h2 基本名称:demo.mv.db

this bug is related to these issues:此错误与以下问题有关:

When running the application, the log will show something like nwconfig.DatabaseConfiguration 1: H2 database is available on port 18080. Then change Connection Type to Remote and port to the port just showed, append the db file location to the url (with out extension) just like ./build/h2db/db/projectname , User will be the ProjectName.运行应用程序时,日志将显示类似nwconfig.DatabaseConfiguration 1: H2 database is available on port 18080.然后将连接类型更改为远程,将端口更改为刚刚显示的端口,将 db 文件位置附加到 url(不带扩展名) ) 就像./build/h2db/db/projectname一样,用户将是项目名称。

The final url will like jdbc:h2:tcp://localhost:18080/./build/h2db/db/projectname最终的 url 将像 jdbc:h2:tcp://localhost:18080/./build/h2db/db/projectname

This worked for me, I'm not a English native speaker, sorry for my poor English.这对我有用,我不是以英语为母语的人,对不起我的英语不好。

To resolve this issue I installed Buddy JPA plugin.为了解决这个问题,我安装了 Buddy JPA 插件。 It created profile automatically and I compared it with mine.它自动创建了配置文件,我将其与我的进行了比较。 the difference was in parameter DB_CLOSE_ON_EXIT=FALSE I tried it with manually created profile and it works as well.不同之处在于参数DB_CLOSE_ON_EXIT=FALSE我用手动创建的配置文件尝试过它,它也能正常工作。 The result link is:结果链接是:

jdbc:h2:file:./work/h2db;DB_CLOSE_ON_EXIT=FALSE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM