Skip to content

Commit

Permalink
修复启动错误
Browse files Browse the repository at this point in the history
  • Loading branch information
sgjj committed Aug 9, 2019
1 parent e8f2f84 commit 4f54ae2
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/main/java/net/mingsoft/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,23 @@ public void addInterceptors(InterceptorRegistry registry) {

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {

registry.addResourceHandler("/upload/**").addResourceLocations("file:" + BasicUtil.getRealPath("upload") + File.separator);
registry.addResourceHandler("/html/**").addResourceLocations("file:" + BasicUtil.getRealPath("html") + File.separator);
registry.addResourceHandler("/templets/**").addResourceLocations("file:" + BasicUtil.getRealPath("templets") + File.separator);
registry.addResourceHandler("/app/**").addResourceLocations("file:" + BasicUtil.getRealPath("app") + File.separator, "classpath:/app/");
registry.addResourceHandler("/static/**").addResourceLocations("file:" + BasicUtil.getRealPath("static") + File.separator, "classpath:/static/");
registry.addResourceHandler("/api/**").addResourceLocations("file:" + BasicUtil.getRealPath("api") + File.separator, "classpath:/api/");
//jar包方式映射处理
String classPath = BasicUtil.getClassPath("");
if (classPath.startsWith("file")) {
registry.addResourceHandler("/upload/**").addResourceLocations("file:" + BasicUtil.getRealPath("upload") + File.separator);
registry.addResourceHandler("/html/**").addResourceLocations("file:" + BasicUtil.getRealPath("html") + File.separator);
registry.addResourceHandler("/templets/**").addResourceLocations("file:" + BasicUtil.getRealPath("templets") + File.separator);
} else {
//必须做判断,不然jar运行的html路径会被覆盖掉
registry.addResourceHandler("/html/**").addResourceLocations("/html/");
}
registry.addResourceHandler("/app/**").addResourceLocations("/app/", "classpath:/app/");
registry.addResourceHandler("/static/**").addResourceLocations("/static/", "classpath:/static/");
registry.addResourceHandler("/api/**").addResourceLocations("/api/", "classpath:/api/");
}

/**
* druidServlet注册
*/
/**
* druidServlet注册
*/
@Bean
public ServletRegistrationBean druidServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet());
Expand Down

0 comments on commit 4f54ae2

Please sign in to comment.