【发布时间】:2016-07-05 22:45:03
【问题描述】:
我按照link(直到步骤 5.1)中列出的步骤来集成 swagger 文档。下面是我的控制器类的样子。当我尝试使用 url > http://localhost:8080/greetingservice/swagger-ui.html
访问类似于文档中描述的文档时出现 404 错误但是我看到使用 url http://localhost:8080/swagger-ui.html#!/greeting-controller/greetingUsingGET 的文档
我希望文档的显示方式与应用程序特定的上下文路径下的文档中提及的方式类似。你能告诉我我错过了什么吗?
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.comcast.rapid.ctp.springfox.service.model.Greeting;
@RequestMapping("/greetingservice")
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@RequestMapping(method={RequestMethod.GET}, value="{apiName}", produces=MediaType.APPLICATION_JSON_VALUE)
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name,@PathVariable String apiName) {
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
}
}
【问题讨论】:
标签: java spring spring-boot swagger springfox