Spring 无法访问Swagger端点
我有一个SpringMVC项目,它使用gradle来构建这个项目 我使用了这个项目中描述的步骤 build.gradle文件具有以下swagger条目:Spring 无法访问Swagger端点,spring,spring-mvc,swagger,Spring,Spring Mvc,Swagger,我有一个SpringMVC项目,它使用gradle来构建这个项目 我使用了这个项目中描述的步骤 build.gradle文件具有以下swagger条目: compile (libraries.swagger){ exclude group:'org.slf4j', module:'slf4j-log4j12' exclude group:'org.slf4j', module:'slf4j-api' exclude group:'junit', module:'jun
compile (libraries.swagger){
exclude group:'org.slf4j', module:'slf4j-log4j12'
exclude group:'org.slf4j', module:'slf4j-api'
exclude group:'junit', module:'junit'
}
swagger的配置在project build.gradle中完成,如下所示:
swagger: "com.knappsack:swagger4spring-web:0.3.3"
我的文档结束点控制器是:
import com.knappsack.swagger4springweb.controller.ApiDocumentationController;
import com.wordnik.swagger.model.ApiInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* This is an example of how you might extend the ApiDocumentationController in order to set your
* own RequestMapping (instead of the default "/api") among other possibilities. Going this route,
* you do not necessarily have to define the controller in your servlet context.
*/
@Controller
@RequestMapping(value = "/documentation")
public class SwaggerDocumentationController extends ApiDocumentationController {
public SwaggerDocumentationController() {
setBaseControllerPackage("com.controller");
setBaseModelPackage("com.domain");
setApiVersion("v1");
ApiInfo apiInfo = new ApiInfo("swagger",
"This is a basic web app for demonstrating swagger",
"http://localhost:9999/terms", "http://localhost:9999/contact", "MIT",
"http://opensource.org/licenses/MIT");
setApiInfo(apiInfo);
}
@RequestMapping(value = "/", method = RequestMethod.GET)
public String documentation() {
return "documentation";
}
}
然后我尝试访问端点以获取文档,如下所示:http://localhost:9999/myApp/documentation/test
测试是控制器内部提到的映射,如下所示:
@Api(value = "test",
description = "A test controller to see if the services are up and running.")
@RequestMapping(value = {"/test"}, method = {RequestMethod.GET})
我在访问上面的文档URL时遇到了404 not found错误。我错过什么了吗
如果需要更多信息,请务必告诉我
请帮忙 我有用户招摇过市的springmvc,它工作得很好。您可以从以下url尝试
专家们,我正在本地计算机上使用JDK 7。