H2 Console 访问变成下载文件

本文介绍了H2Console从HTTP转换为HTTPS过程中遇到的问题及解决方法。由于在H2Console中启用了加密SSL连接,导致原本正常的HTTP访问变为文件下载。通过调整配置或使用HTTPS方式重新访问解决了该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述:H2 console 启动端口8110.通过地址http://127.0.0.1:8110/一直可以正常访问。

但是突然变成访问地址时变成了下载文件。

原因: 之前在H2 console的Preferences 菜单设置了 Use encrypted SSL (HTTPS) connections选项。

                点击Save

用https://127.0.0.1:8110/就可以了。

发现选择了这个选项会在用户目录生成.h2.keystore 和.h2.server.properties文件。

.h2.server.properties 为h2的配置文件在点击Save时生成.

里面记录了

webAllowOthers=false

webPort=8110

webSSL=true

如果启动不给定某项配置会从这里读取。所以在设置完后启动用http登录变成了下载文件。

手动修改这个文件或者删除或者https访问console设置点保存重启h2 server 就可以了


<resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>*.properties</include> <include>*.yml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <includes> <include>*.sql</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <includes> <include>static/**</include> </includes> <targetPath>${project.build.outputDirectory}</targetPath> </resource> </resources> server.port=8081 server.servlet.context-path=/demo logging.level.com.esoft.crm.mapper=debug spring.datasource.url=jdbc:h2:file:./test;MODE=MySQL;CASE_INSENSITIVE_IDENTIFIERS=TRUE;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false spring.datasource.driver-class-name=org.h2.Driver spring.datasource.username=sa spring.datasource.password= spring.h2.console.enabled=true spring.h2.console.path=/h2-console #spring.sql.init.mode=always #spring.sql.init.schema-locations=classpath:schema.sql #spring.sql.init.data-locations=classpath:data.sql spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect logging.level.org.hibernate.SQL=debug logging.level.org.hibernate.type.descriptor.sql=trace spring.datasource.hikari.connection-timeout=30000 spring.datasource.hikari.maximum-pool-size=10 #spring.sql.init.mode=always #spring.sql.init.schema-locations=classpath:schema.sql #spring.sql.init.data-locations=classpath:data.sql spring.datasource.schema=classpath:schema.sql spring.datasource.data=classpath:data.sql spring.datasource.initialization-mode=always spring.web.resources.static-locations=classpath:/static/ spring.mvc.static-path-pattern=/static/** mybatis.mapper-locations=classpath:mapper/*.xml mybatis.type-aliases-package=com.esoft.crm.po,com.esoft.crm.vo 且前端页面资源(css,img,index.html)等都存在与resource/static下,且没有打包,直接在idea环境下运行,运行后前端打不开,报错GET http://localhost:8080/js/chunk-vendors.1a0a0613.js net::ERR_CONNECTION_REFUSED :8080/img/icons/favicon-32x32.png:1 GET http://localhost:8080/img/icons/favicon-32x32.png net::ERR_CONNECTION_REFUSED :8080/img/icons/android-chrome-192x192.png:1 GET http://localhost:8080/img/icons/android-chrome-192x192.png net::ERR_CONNECTION_REFUSED :8080/img/icons/favicon-16x16.png:1 GET http://localhost:8080/img/icons/favicon-16x16.png net::ERR_CONNECTION_REFUSED localhost/:1 Error while trying to use the following icon from the Manifest: http://localhost:8080/img/icons/android-chrome-192x192.png (Download error or resource isn't a valid image),访问http://localhost:8081/demo/static/js/chunk-vendors.1a0a0613.js成功,内容是...//# sourceMappingURL=chunk-vendors.1a0a0613.js.map
07-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值