繁体   English   中英

如何更改Spring Boot H2控制台的端口

[英]How to change the port of the spring boot h2 console

我正在尝试查看Spring Boot H2控制台。 但是,默认端口为8080,并且该端口已在我的计算机上使用。

有没有办法改变spring boot用于h2的Web端口? 关于更改路径,有很多文档,但是我找不到有关更改端口的任何信息。 这是我当前的配置设置:

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true
spring.jpa.database=h2

编辑如下面的Atul K所述,h2 Web控制台可在已配置的server.port 但是,这对我来说不是一个选择,因为我们的Spring Boot应用程序会对进入Spring Boot应用程序的所有请求执行强制标头验证。 是否可以为h2 Web控制台和spring boot应用程序独立配置端口?

server.port=8081添加到您的配置中。 作为其嵌入式,应使用与服务端口相同的端口。 因此应该能够使用url访问它: http:// localhost:8081 / h2-console

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM