在应用程序启动时启动 HSQLDB 数据库管理器?
当我在本地开发环境中工作时,是否可以以某种方式自动启动 HSQLDB 数据库管理器?我现在正在使用内存数据库。我找到了一些在运行测试用例时启动数据库管理器的代码。启动 Web 应用程序时也可以使用它吗?
org.hsqldb.util.DatabaseManagerSwing.main(new String[] { "--url","jdbc:hsqldb:mem:moviecollection", "--noexit" });
Is it possible to start the HSQLDB Database manager automatically somehow when I´m working in my local dev environment? I´m using the in-memory DB at the moment. I found some code to start the database manager when running test cases. Can this be used when starting a web application as well?
org.hsqldb.util.DatabaseManagerSwing.main(new String[] { "--url","jdbc:hsqldb:mem:moviecollection", "--noexit" });
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设您正在使用 Spring,因为您用它标记了您的问题。您可以创建一个 Spring bean,该 bean 的方法使用 JSR-250 注释进行注释
@PostConstruct
。用@PostConstruct
注解的方法指示应在创建 bean 并完成依赖项注入后调用该方法。如果您使用 Web 应用程序启动
DatabaseManagerSwing
,它将被创建并显示在运行 WAR 的服务器上,而您可能不想这样做。I am assuming you are using Spring because you tagged your question with it. You could create a Spring bean that has a method that is annotated with the JSR-250 annotation
@PostConstruct
. Method annotated with@PostConstruct
indicates that the method should be invoked after the bean has been created and dependency injection is complete.If you would start the
DatabaseManagerSwing
with a web application it would get created and displayed on the server your WAR is running on which you probably don't want to do.您不需要明确地启动它。如果您配置连接 url 并添加 jars 就足够了。
You did not need to start it explicite. It is enougth if you configure the connection url and add the jars.
如果你使用maven尝试执行java程序< /a>,将其绑定到 deploy 目标,
我确信基于 ant 的项目有类似的解决方案
if you use maven try exec java program, bind it to the deploy goal
i am sure there are similiar solutions for ant based projects