-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...agger-ext-spring-samples/src/main/java/cn/chenzw/swagger/ext/spring/config/AppConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package cn.chenzw.swagger.ext.spring.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class AppConfig { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...agger-ext-spring-samples/src/main/java/cn/chenzw/swagger/ext/spring/config/WebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cn.chenzw.swagger.ext.spring.config; | ||
|
||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
|
||
@Configuration | ||
@ComponentScan(basePackages = {"cn.chenzw.swagger.ext.spring"}) | ||
@EnableWebMvc | ||
public class WebConfig extends WebMvcConfigurerAdapter { | ||
|
||
@Override | ||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
registry.addResourceHandler("/**").addResourceLocations( | ||
"classpath:/static/"); | ||
// 指定swagger-ui.html页面的路径 | ||
registry.addResourceHandler("swagger-ui.html").addResourceLocations( | ||
"classpath:/META-INF/resources/"); | ||
registry.addResourceHandler("/webjars/**").addResourceLocations( | ||
"classpath:/META-INF/resources/webjars/"); | ||
super.addResourceHandlers(registry); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...spring-samples/src/main/java/cn/chenzw/swagger/ext/spring/initializer/WebInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cn.chenzw.swagger.ext.spring.initializer; | ||
|
||
import cn.chenzw.swagger.ext.spring.config.AppConfig; | ||
import cn.chenzw.swagger.ext.spring.config.WebConfig; | ||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; | ||
|
||
public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { | ||
|
||
@Override | ||
protected Class<?>[] getRootConfigClasses() { | ||
return new Class[]{AppConfig.class}; | ||
} | ||
|
||
@Override | ||
protected Class<?>[] getServletConfigClasses() { | ||
return new Class[]{WebConfig.class}; | ||
} | ||
|
||
@Override | ||
protected String[] getServletMappings() { | ||
return new String[]{"/"}; | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
swagger-ext-samples/swagger-ext-spring-samples/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@echo off | ||
|
||
mvn tomcat7:run | ||
mvn tomcat7:run | ||
|
||
@rem start chrome.exe http://localhost:8080/swagger-ext-spring-samples/swagger-ui.html |