본문 바로가기

Spring Boot28

Spring Actuator와 Swagger가 서로 충돌할때 정확한 원인은 Spring Boot 2.X와 Springfox 3.0.0이 서로 충돌하여 발생하는 문제입니다. 방법 1 (Bean 등록) @Bean public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() { return new BeanPostProcessor() { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvid.. 2023. 9. 19.
[Spring] REST API로 파일 보내기 @GetMapping(value = "", produces = "application/json;charset=utf-8") public ResponseEntity getFile( @RequestParam(value = "fileName", required = false) String fileName) throws IOException { ResponseEntity respEntity = null; File result = new File("YOUR_PATH" + fileName); if (result.exists()) { InputStream inputStream = new FileInputStream("YOUR_PATH" + fileName); String type = URLConnection.gues.. 2023. 8. 10.
[Swagger] swagger-ui.html 접속 url 변경하기 (리다이렉트) @SpringBootApplication public class MyApp { public static void main(String[] args) { SpringApplication.run(MyApp.class, args); } @Bean RouterFunction routerFunction() { return route(GET("/swagger"), req -> ServerResponse.temporaryRedirect(URI.create("swagger-ui.html")).build()); } } 위와 같이 빈으로 등록해주면, localhost:8080/swagger로 접속하였을때 localhost:8080/swagger-ui.html로 리다이렉트 해줍니다. ref : https://github.c.. 2023. 8. 9.
[Spring] 타임리프에서 Spring Service 호출하기 ... @Service 어노테이션으로 빈에 등록되어 사용이 가능합니다. ref : https://stackoverflow.com/questions/43841458/how-to-call-a-service-method-with-thymeleaf 2023. 8. 8.