我遵循此link中列出的步驟(直到步驟5.1)來集成swagger文檔。下面是我的控制器類的樣子。我得到一個404錯誤,當我嘗試訪問類似,它是如何在文檔中使用URL>http://localhost:8080/greetingservice/swagger-ui.htmlSpringFox Swagger與Springboot應用程序的集成
但是我看到使用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));
}
}