运行Spring Boot JAR应用程序无法通过浏览器打开URL(https:// localhost:8080 /)

问题描述 投票:0回答:2

我有一个Spring Boot JAR应用程序。当我运行它时,没有浏览器会自动显示https://localhost:8080/。但是,手动键入提到的URL可以很好地运行应用程序。

@SpringBootApplication
@ImportResource({ "classpath:applicationContext.xml" })
public class StockMaintenanceSystemApplication extends WebMvcConfigurerAdapter {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(StockMaintenanceSystemApplication.class, args);
    }

}

我需要在任何地方设置URL(https://localhost:8080/)吗?如果没有,请更正我的代码。

java spring-boot
2个回答
1
投票

如果我理解正确,则表示启动Spring Boot应用程序时浏览器不会打开新选项卡。

如果是这种情况,则不应打开新选项卡,它只是在您的PC上启动一项服务,您需要手动导航至该地址。弹簧靴根本就不行。


1
投票

构建并运行jar文件时,它不会自动为您打开浏览器。在服务器环境上部署时使用文件jar,这与您仍然习惯的开发人员环境完全不同,在使用IDE时,您的工作就是单击“运行按钮”,IDE将会构建jar文件,运行它并自动为您打开浏览器。

这里的解决方案是,您可以编写执行诸如that之类的shell命令并在main函数上调用它的函数。 shell命令可以是chrome.exe localhost:8080

© www.soinside.com 2019 - 2024. All rights reserved.