【springBoot】加了CommandLineRunner之后静态文件找不到了

我的大神梦 我的大神梦 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
加了CommandLineRunner之后页面打开后js和css都报404了,请教下原因

指改动了两个地方
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();
}
}
}
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
我的大神梦
Java EE 67,535 成员 225,843 内容