स्वैगर दस्तावेज़ तक पहुँचने का प्रयास करते समय, मुझे इस त्रुटि का सामना करना पड़ता है:
व्हाइटलेबल त्रुटि पृष्ठ इस एप्लिकेशन में /त्रुटि के लिए कोई स्पष्ट मानचित्रण नहीं है, इसलिए आप इसे एक फ़ॉलबैक के रूप में देख रहे हैं।
बुध सितम्बर 23 09:38:17 BRT 2020 एक अप्रत्याशित त्रुटि थी (प्रकार = नहीं मिला, स्थिति = 404)। कोई संदेश उपलब्ध नहीं
मुझे नहीं पता कि क्या हो सकता है...
पोम.एक्सएमएल:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
कक्षा विन्यास:
package com.simulacao.api.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket bancoApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.simulacao.api"))
.paths(PathSelectors.regex("/*.*"))
.build()
.apiInfo(metaInfo());
}
private ApiInfo metaInfo() {
return new ApiInfoBuilder()
.title("API Rest")
.description("\"API Rest\"")
.version("1.0.0")
.license("Apache License Version 2.0")
.licenseUrl("https://www.apache.org/licenses/LICENSE-2.0\"")
.build();
}
}
नियंत्रक:
@RestController
@RequestMapping(value = "/api/customer")
@Api(value = "API Rest Customer")
@CrossOrigin(origins = "*")
public class CustomerController {
@Autowired
private CustomerService customerService;
@Autowired
private AccountService accountService;
@Autowired
private CustomerRepository customerRepository;
@GetMapping
@ApiOperation(value = "Returns a list of customers")
public ResponseEntity<List<Customer>> showAll() {
return ResponseEntity.ok(this.customerService.findAll());
}
2 जवाब
कृपया उन विन्यासों को जोड़ें
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//Swagger UI property
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
इसे "WebMvcConfigurer" के साथ कार्यान्वयन की कॉन्फ़िगरेशन में घोषित किया जाना चाहिए।
अधिक जानकारी यहां : https://springfox.github.io/springfox/docs/current/< /ए>
स्प्रिंगफॉक्स 3 के साथ स्प्रिंग बूट के लिए आपको बस निम्नलिखित की आवश्यकता है:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
और /swagger-ui.html
अब /swagger-ui/index.html
या /swagger-ui
है। doc से
swagger-ui स्थान http://host/context-path/swagger-ui.html से http://host/context-path/swagger-ui/index.html या http://host/context-path पर स्थानांतरित हो गया है /स्वैगर-यूआई/ संक्षेप में
संबंधित सवाल
नए सवाल
java
जावा एक उच्च स्तरीय प्रोग्रामिंग भाषा है। इस टैग का उपयोग तब करें जब आपको भाषा का उपयोग करने या समझने में समस्या हो। इस टैग का उपयोग शायद ही कभी किया जाता है और इसका उपयोग अक्सर [वसंत], [वसंत-बूट], [जकार्ता-ई], [Android], [javafx], [हडूप], [श्रेणी] और [मावेन] के साथ किया जाता है।