简体   繁体   English

如何外部化data.sql以用于Spring Boot应用程序

[英]How to externalise data.sql for a spring boot app

I always use data.sql file in my resource folder if I want to initialise my H2 database with spring boot. 如果我想用Spring Boot初始化H2数据库,我总是在资源文件夹中使用data.sql文件。

Now I need to use a H2 database but also to externalise data.sql in order to update this file when there are any changes. 现在,我需要使用H2数据库,还需要外部化data.sql ,以便在进行任何更改时更新此文件。

I don't want to install MySql or other Databases because it's a very small service with a few database items and this service may be restarted sometimes. 我不想安装MySql或其他数据库,因为它是一个很小的服务,只有几个数据库项,并且有时可能会重新启动该服务。

So I have my folder in which there are the following two files: the uber jar file of my spring boot application (with Tomcat embedded) and data.sql file. 因此,我的文件夹中包含以下两个文件:Spring Boot应用程序的Uber jar文件(嵌入Tomcat )和data.sql文件。

How can I externalise data.sql like the way I can externalise the configurations for application.properties ? 如何像将application.properties的配置外部一样,将data.sql外部化?

运行jar时将其放在类路径中怎么样?

java -jar uber.jar -classpath "PATH_TO_YOUR_SQL_FILE"

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

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