Thank you Mikey! I have the same problem! In fact, take a look
grails-app/conf/DataSource.groovy
At least in my case, the JDBC URL can be set to jdbc: h2: mem: devDb for the development database, jdbc:h2:mem:testDb for the test database and jdbc:h2:mem:prodDb for the production database.
The console does not have the ability to find out which one you prefer, so it checks by default. In addition, if you click "JDBC URL" in dbconsole mode in a browser, it will show you some tips. In particular, it explains that “The jdbc: h2: ~ / test URL means that the database is stored in the user's home directory in files starting with“ test. ”Indeed, I now have test.h2.db in my home directory test.h2.db , test.lock.db and test.trace.db . This also explains why the data is not saved by default. Didn't you notice that when you set the default every time you restart Grails, you need to recreate all the objects ? Well, this is because of the ": mem:" part in the JDBC URL.
This default value is probably not related to Grails; I would suggest that H2 simply creates a test database in your default home directory unless otherwise noted. I also assume that you can have many different databases in a complex production environment, which is why Grails is not trying to guess what exactly you want.
Also see official H2 documentation
osa
source share