当前位置: 首页 > 知识库问答 >
问题:

如何使用Netbeans Spring-Boot项目访问h2-console

秦焱
2023-03-14
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <!--WebJars-->
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.3.5</version>
     </dependency>
     <dependency>
         <groupId>org.webjars</groupId>
         <artifactId>jquery</artifactId>
         <version>3.2.1</version>
     </dependency>

     <!--jpa and database-->
     <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-data-jpa</artifactId>
     </dependency>
     <dependency>
         <groupId>com.h2database</groupId>
         <artifactId>h2</artifactId>
         <scope>runtime</scope>
     </dependency>

</dependencies>
2017-07-19 01:35:25.222  INFO 8644 --- [           main] c.e.s.SpringBootTest00Application        : Starting SpringBootTest00Application on DESKTOP-K8Q0B2R with PID 8644 (started by Talon in C:\Users\Talon\Desktop\java netbeans\01\springBootTest00)
2017-07-19 01:35:25.225  INFO 8644 --- [           main] c.e.s.SpringBootTest00Application        : No active profile set, falling back to default profiles: default
2017-07-19 01:35:25.544  INFO 8644 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@37574691: startup date [Wed Jul 19 01:35:25 CEST 2017]; root of context hierarchy
2017-07-19 01:35:27.236  INFO 8644 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-19 01:35:27.248  INFO 8644 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-07-19 01:35:27.249  INFO 8644 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-07-19 01:35:27.378  INFO 8644 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-07-19 01:35:27.378  INFO 8644 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1838 ms
2017-07-19 01:35:27.578  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-07-19 01:35:27.582  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-07-19 01:35:27.584  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-07-19 01:35:27.584  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-07-19 01:35:27.584  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-07-19 01:35:28.020  INFO 8644 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-07-19 01:35:28.037  INFO 8644 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-07-19 01:35:28.122  INFO 8644 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.0.12.Final}
2017-07-19 01:35:28.123  INFO 8644 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2017-07-19 01:35:28.180  INFO 8644 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2017-07-19 01:35:28.219  INFO 8644 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-07-19 01:35:28.321  INFO 8644 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2017-07-19 01:35:28.742  INFO 8644 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export
2017-07-19 01:35:28.757  INFO 8644 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000230: Schema export complete
2017-07-19 01:35:28.809  INFO 8644 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-07-19 01:35:29.119  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@37574691: startup date [Wed Jul 19 01:35:25 CEST 2017]; root of context hierarchy
2017-07-19 01:35:29.203  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.example.springBootTest00.controllers.IndexController.index()
2017-07-19 01:35:29.205  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product],methods=[POST]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.saveOrUpdateProduct(com.example.springBootTest00.domain.Product)
2017-07-19 01:35:29.206  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/edit/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.edit(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.206  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/new]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.newProduct(org.springframework.ui.Model)
2017-07-19 01:35:29.206  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/delete/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.deleteProduct(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.206  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/products]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.listProducts(org.springframework.ui.Model)
2017-07-19 01:35:29.206  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.getProduct(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.209  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-07-19 01:35:29.209  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-07-19 01:35:29.243  INFO 8644 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.244  INFO 8644 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.284  INFO 8644 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.920  INFO 8644 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-07-19 01:35:29.983  INFO 8644 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-07-19 01:35:29.987  INFO 8644 --- [           main] c.e.s.SpringBootTest00Application        : Started SpringBootTest00Application in 5.052 seconds (JVM running for 5.401)

共有1个答案

汪晨
2023-03-14

用简单的步骤编写:

application.properties文件中包括

spring.h2.console.path=/h2
spring.h2.console.enabled=true

并且在pom.xml中包含devtools依赖项

       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-devtools</artifactId>
          <optional>true</optional>
      </dependency>
spring.datasource.url=jdbc:h2:file:~/h2db
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
 类似资料:
  • 使用webflux时,无法在localhost:8080/H2控制台访问H2 db。我在某处读到,这只有在开发基于Servlet的应用程序时才可用。但我正在使用Webflux和Netty。那么,有没有办法在这样的应用程序中查看h2控制台呢?

  • 我有1个根项目和3个模块(api,模型,存储)在其中。以下是项目结构: 在我的application.java中,我试图从参考资料中读取CSV文件: 解决了此代码工作良好: 要了解更多详细信息,请检查以下答案:作为jar运行时未找到classpath资源

  • 本文向大家介绍React 使用browserHistory项目访问404问题解决,包括了React 使用browserHistory项目访问404问题解决的使用技巧和注意事项,需要的朋友参考一下 最近项目里面用到了React但是发布到iis站点之后,路由地址 刷新访问直接404错误。查阅资料之后发现是iis缺少配置URL重写 的问题导致的。下面我们来图形化配置,简单的配置下IIS 打开IIS使用

  • 问题内容: 我刚刚开始在Java中使用json。我不确定如何访问JSONArray中的字符串值。例如,我的json看起来像这样: 我的代码: 我现在可以访问“ record” JSONArray,但是不确定如何在for循环中获取“ id”和“ loc”值。抱歉,如果此说明不太清楚,我对编程有点陌生。 问题答案: 您是否尝试过使用JSONArray.getJSONObject(int)和JSONAr

  • 我只是使用Spring Boot初始化器创建基本和子两个项目,并使用最简单的多个项目。我在根处设置settings.gradle以包括'base'、'sub'。我还在sub/gradle.build中添加了compile project(':base')依赖项。当我在根文件夹中运行gradle build时,当execute:sub:compileJave任务和报表无法从基本项目中找到一些包时,它

  • 在Spring Boot项目中,我试图从我的IDE中查看内存中的表。 如何从Intellij IDEA访问内存中的h2数据库。 这是我的应用程序的一个片段。yml: