问题描述
要么我错过了一些文档(Spring,Spring Boot,H2,HSQLDB,Derby,IntelliJ)中深层的核心概念,要么我一直在盯着这个主题呆了太长时间.
Either I'm missing some core concept buried deep within some documentation (Spring, Spring Boot, H2, HSQLDB, Derby, IntelliJ) or I've been staring at this for too long.
我有一个Spring Boot项目.首先尝试使用和初始化H2数据库,尝试在IntelliJ中连接到它只是为了意识到我可能无法在不放弃我的长子的情况下轻松浏览数据库().
I have a Spring Boot project going. Tried using and initializing an H2 DB at first, tried connecting to it in IntelliJ only to realize that I might not be able to easily browse the db without giving up my firstborn child (Connect to H2 database using IntelliJ database client).
所以我搬到了DerbyDB.同样的事情-在我的应用程序中创建了db根文件夹,我在IntelliJ中连接到它,但是从启动该应用程序创建的表却无法浏览.
So I moved to DerbyDB. Same thing - db root folder is created in my app, I connect to it in IntelliJ but my tables, that were just created from starting the app are not available to browse.
我什至尝试了SQLite,但是对SQLite的支持不够好,某些更新功能不可用,但是我至少可以在IntelliJ浏览器中找到我的表!
I even tried SQLite, but support for SQLite is not as good and certain update functions were not available, but I could atleast find my tables in IntelliJ browser!
我只想要一个简单的单文件嵌入式DB,我可以轻松使用,浏览和玩它.有什么建议吗?!
I just want a simple single file embedded DB that I can use, browse, and play with easily. Any suggestions?!
运行该应用程序时,我看到该模式已导出:
When I run the application, I see that the schema is exported:
2015-07-19 09:37:45.836 INFO 98608 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
Hibernate: drop table user_roles if exists
Hibernate: drop table users if exists
Hibernate: create table user_roles (id bigint generated by default as identity, role_name varchar(255), version bigint, user_id bigint, primary key (id))
Hibernate: create table users (id bigint generated by default as identity, email varchar(255), password varchar(255), username varchar(255), version bigint, primary key (id))
Hibernate: alter table user_roles add constraint FK_g1uebn6mqk9qiaw45vnacmyo2 foreign key (user_id) references users
2015-07-19 09:37:45.849 INFO 98608 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
在IntelliJ中,什么都不做(根据heenenee的建议,使用jdbc:h2:./test; AUTO_SERVER = TRUE的远程源):
In IntelliJ, nothing (using a remote source of jdbc:h2:./test;AUTO_SERVER=TRUE as per heenenee suggestion):
我看到一些投票要结束,因为不清楚我在问什么:
I see some votes to close because its unclear what I'm asking:
如何使用H2,HSQLDB或Derby数据库开发应用程序并通过IntelliJ连接到它们?
How do I develop applications using H2, HSQLDB, or Derby databases and connect to them with IntelliJ?
推荐答案
H2 Automatic Mixed Mode should be fine for you. Use jdbc:h2:~/mydbInHomeDir;AUTO_SERVER=TRUE
as your spring.datasource.url
. In IntelliJ, create a remote H2 data source and use the exact same JDBC URL. You may have to explicitly press the Synchronize button in the IntelliJ Database window to get the database tables to show up.
这篇关于Spring Boot + IntelliJ +嵌入式数据库=头痛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!