我在Rest Web服务(Apache CXF和Spring)中添加了swagger。然而,当我尝试在我的招摇式json url中导航时,什么都没有发生,什么都没有显示。下面是我的配置文件。
-CXF版本3.1.6
导航到此URL时
http://localhost:9080/api/swagger.json
尝试阅读这里的其他帖子,但没有一个奏效。请给我点光。谢谢
<jaxrs:inInterceptors>
<ref bean="validationInInterceptor" />
</jaxrs:inInterceptors>
<jaxrs:providers>
<ref bean="jsonProvider" />
<ref bean="exceptionMapper" />
</jaxrs:providers>
<jaxrs:serviceBeans>
<ref bean="myWebServiceRs" />
</jaxrs:serviceBeans>
<jaxrs:features>
<ref bean="swagger2Feature" />
</jaxrs:features>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
</jaxrs:server>
<bean id="jsonProvider"
class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:resources location="classpath:/META-INF/resources/webjars/swagger-ui/3.0.3" mapping="/api/**" />
<bean id="swagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature" >
指数html
window.onload = function() {
alert("entry!");
// Build a system
const ui = SwaggerUIBundle({
url: "/api/swagger.json",
validatorUrl : null,
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
// yay ES6 modules â
Array.isArray(SwaggerUIStandalonePreset) ? SwaggerUIStandalonePreset : SwaggerUIStandalonePreset.default
],