Как просмотреть H2-консоль при использовании конфигурации на основе Xml спящего режима?
Я должен настаивать на следующем занятии
public class Hotel {
@Id
private String hotelName;
private String RoomType;
private String status;
private int Price;
private int gst;
мой файл Hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<!-- JDBC Database connection settings -->
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.url">jdbc:h2:mem:test</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!-- JDBC connection pool settings ... using built-in test pool -->
<property name="connection.pool_size">1</property>
<!-- Select our SQL dialect -->
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
<!-- Echo the SQL to stdout -->
<property name="show_sql">true</property>
<!-- Set the current session context -->
<property name="current_session_context_class">thread</property>
<property name="hbm2ddl.auto">create-drop</property>
<mapping class="com.wipro.BED1.Hotel" />
</session-factory>
моя консоль показывает это, но я могу использовать консоль h2 для просмотра таблицы, поскольку я хочу видеть обычную таблицу.
INFO: HHH10001003: Autocommit mode: false
Apr 14, 2021 11:38:41 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Apr 14, 2021 11:38:42 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Hibernate: drop table if exists hotels CASCADE
Apr 14, 2021 11:38:43 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@1a4d1ab7] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
Hibernate: create table hotels (hotelName varchar(255) not null, Price integer not null, RoomType varchar(255), gst integer not null, status varchar(255), primary key (hotelName))
Apr 14, 2021 11:38:43 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@761e788f] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
Hibernate: insert into hotels (Price, RoomType, gst, status, hotelName) values (?, ?, ?, ?, ?)
2 ответа
Решение
Весной Servlet.xml я бы использовал следующее свойство bean-компонента:
<bean id="h2Server"class="org.h2.tools.Server" factory-method="createWebServer"init-method="start"destroy-method="stop">
<constructor-arg value="-web,-webAllowOthers,-webPort,8086"/>
</bean>
Есть свойство, которое вы установили в значение true
spring.h2.console.enabled=true
Попробуй, должно сработать