java - How to connect H2 console to embedded Spring H2 DB -


ok, im developing simple app, has spring ebedded h2 database development. database.xml bean conf looks this:

<bean id="h2server" class="org.h2.tools.server" factory-method="createtcpserver"         init-method="start" destroy-method="stop" depends-on="h2webserver">         <constructor-arg value="-tcp,-tcpallowothers,-tcpport,9092" />     </bean>     <bean id="h2webserver" class="org.h2.tools.server" factory-method="createwebserver"         init-method="start" destroy-method="stop">         <constructor-arg value="-web,-weballowothers,-webport,8082" />     </bean>      <jdbc:embedded-database id="datasource" type="h2" /> 

h2 database initializing, app working, im creating entities, , stored in h2 db when tomcat launched (i know because use , retrieve them). however, when @ h2 console, entity tables not present.

i guess h2 console points on h2 database, , spring embedded h2 db not related h2 console.

how fix that?

edit: im getting access h2 console typing http://localhost:8082 in web browser.

if application not spring boot need add below servlet configuration in web.xml file

!-- h2 database console managing app's database --> <servlet>     <servlet-name>h2console</servlet-name>     <servlet-class>org.h2.server.web.webservlet</servlet-class>     <init-param>         <param-name>-weballowothers</param-name>         <param-value>true</param-value>     </init-param>     <load-on-startup>2</load-on-startup> </servlet>  <servlet-mapping>     <servlet-name>h2console</servlet-name>     <url-pattern>/admin/h2/*</url-pattern> </servlet-mapping>  <!-- handles requests application --> 

please see more details https://github.com/spring-projects/greenhouse/blob/master/src/main/webapp/web-inf/web.xml

and if application spring boot based have follow https://springframework.guru/using-the-h2-database-console-in-spring-boot-with-spring-security/


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -