Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start the H2 database in server mode via Spring

I'm trying to start the H2 database in server mode (I want it to run in a different process) via Spring. Currently I'm using java Runnable.exec to start the h2 database (using the command: "java -cp h2.jar org.h2.tools.Server")

I know that there is a way to do it via Spring. I tried to add the following to the spring configuration, but it didn't work (it didn't start the H2 database):

    <bean id="org.h2.tools.Server" class="org.h2.tools.Server"
        factory-method="createTcpServer" init-method="start" destroy-method="stop">
        <constructor-arg value="-tcp,-tcpAllowOthers,true,-tcpPort,8043" />
    </bean>

    <bean id="org.h2.tools.Server-WebServer" class="org.h2.tools.Server"
        factory-method="createWebServer" init-method="start">
        <constructor-arg value="-web,-webAllowOthers,true,-webPort,8082" />
    </bean>

I would appreciate any help/ideas

like image 517
Lin Avatar asked Oct 01 '09 10:10

Lin


1 Answers

Do you happen to have:

<beans default-lazy-init="true" ...

in your Spring configuration files?

like image 94
Grzegorz Oledzki Avatar answered Oct 16 '22 13:10

Grzegorz Oledzki