【springBoot】加了CommandLineRunner之后静态文件找不到了
加了CommandLineRunner之后页面打开后js和css都报404了,请教下原因
指改动了两个地方
1.在启动类上加了注解@EnableWebMvc
2.增加了如下类
指改动了两个地方
1.在启动类上加了注解@EnableWebMvc
2.增加了如下类
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
/**
* 配置自动启动浏览器
*/
@Component
public class MyCommandRunner implements CommandLineRunner {
@Value("${server.port}")
private String port;
@Override
public void run(String... args) {
try {
Runtime.getRuntime().exec("cmd /c start http://localhost:" + port + "/gxs");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
...全文
相关推荐
springboot CommandLineRunner接口实现自动任务加载功能
主要介绍了springboot CommandLineRunner接口实现自动任务加载功能,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
Spring Boot 启动加载数据 CommandLineRunner的使用
本篇文章主要介绍了Spring Boot 启动加载数据 CommandLineRunner的使用,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
详解Springboot应用启动以及关闭时完成某些操作
主要介绍了详解Springboot应用启动以及关闭时完成某些操作,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
springboot单元测试两种方法实例详解
主要介绍了springboot单元测试两种方法实例详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
详解SpringBoot程序启动时执行初始化代码
主要介绍了详解SpringBoot程序启动时执行初始化代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧


