Springboot integrates jersey2-jaxrs and swagger, can not get swagger.json (404 pages)

problem description

integrate jersey2-jaxrs and swagger to form online documents through Springboot. When accessing local swagger-ui.html, there is only description and no interface data. The following two methods have the same effect.

clipboard.png

clipboard.png

:


http://www.bubuko.com/infodet...

:
clipboard.png

:

clipboard.png

clipboard.png

clipboard.png

clipboard.png

commom/web

swagger
package com.ygj.ucs.common.config;

import com.google.common.base.Predicate;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
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.service.ApiKey;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Arrays;

import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;

@Configuration
@EnableSwagger2
@ComponentScan(basePackages={"com.ygj.ucs.biz.controller"})
public class SwaggerConfig {

@Bean


/* @Bean
public SecurityScheme apiKey() {


}


}

JerseyConfig

package com.ygj.ucs.biz.webapp;

import com.ygj.ucs.biz.controller.CompanyController;
import com.ygj.ucs.biz.controller.TestEsController;
import com.ygj.ucs.biz.controller.TestMqController;
import com.ygj.ucs.biz.controller.UserController;
import com.ygj.ucs.common.exception.GlobalExceptionHandler;
import io.swagger.jaxrs.config.BeanConfig;
import io.swagger.jaxrs.listing.ApiListingResource;
import io.swagger.jaxrs.listing.SwaggerSerializers;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
import org.glassfish.jersey.server.wadl.internal.WadlResource;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;

@Component
@ApplicationPath("ucs")
public class JerseyConfig extends ResourceConfig {


}

controller

clipboard.png

server:
port: 8081

mybatis

mybatis-plus:
mapper-locations: classpath:config/mybatis/mapper/*Mapper.xml
-sharppackage
typeAliasesPackage: com.ygj.ucs.biz.domain
global-config:


-sharp
configuration:


spring:

main:


datasource:


redis

redis:


ssl:

cluster:

nodes:

sentinel:

master:

nodes:


RabbitMQ

rabbitmq:


ygj:
test:


user:


ES

es:
server:


user:


logging:
level:


:

github https://github.com/Hafiz77/In... SwaggerConfig

clipboard.png

clipboard.png


clipboard.png

json
clipboard.png

JerseyConfig remains the same

package com.ygj.ucs.biz.webapp;

import com.ygj.ucs.biz.controller.CompanyController;
import com.ygj.ucs.biz.controller.UserController;
import com.ygj.ucs.common.exception.GlobalExceptionHandler;
import io.swagger.jaxrs.config.BeanConfig;
import io.swagger.jaxrs.listing.ApiListingResource;
import io.swagger.jaxrs.listing.SwaggerSerializers;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
import org.glassfish.jersey.server.wadl.internal.WadlResource;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;

@ Component
@ ApplicationPath ("ucs")
public class JerseyConfig extends ResourceConfig {

public JerseyConfig() {
    register(RequestContextFilter.class);
    register(UserController.class);
    register(CompanyController.class);
    register(GlobalExceptionHandler.class);
    /*register(WadlResource.class);
    register(JerseyAutoConfiguration.class);*/
    this.register(WadlResource.class);
    //packages("com.ygj.ucs.biz.controller");


}

@PostConstruct
public void init() {
    // Register components where DI is needed
    this.configureSwagger();
}

private void configureSwagger() {
    // Available at localhost:port/swagger.json
    this.register(ApiListingResource.class);
    this.register(SwaggerSerializers.class);
    BeanConfig config = new BeanConfig();
    config.setConfigId("springboot-jersey-swagger-docker-example");
    config.setTitle("Spring Boot + Jersey + Swagger + Docker Example");
    config.setVersion("v1");
    config.setContact("wzh");
    config.setSchemes(new String[] { "http", "https" });
    config.setBasePath("ucs");
    //config.setResourcePackage("com.ygj.ucs.common.config");
    config.setResourcePackage("com.ygj.ucs.biz.controller");
    config.setPrettyPrint(true);
    config.setScan(true);
}

}

Feb.23,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bab1-2c2bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bab1-2c2bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?