第一种Nginx,映射到dist文件夹
server {
listen 80;
server_name yourdomain.com;
location / {
root /path/to/your/dist;
try_files $uri $uri/ /index.html;
}
}
第二种把dist放到项目中
使用 Spring Boot 结合前端资源,使用 WebMvcConfigurer 来注册静态资源路径
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// 配置静态资源路径
registry.addResourceHandler("/**") // 映射所有路径
.addResourceLocations("dist文件夹路径"); // 指向 dist 文件夹
}
}
标签:dist,后端,springframework,org,WebMvcConfigurer,import,annotation,打包
From: https://www.cnblogs.com/zhao-zong-yu-hai/p/18520953