Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 알기쉬운 알고리즘
- list 컬렉션
- Selection Sorting
- Serialization
- R
- insertion sort
- buffer
- 이것이 자바다
- Stack
- stream
- C programming
- Graph
- 이스케이프 문자
- s
- Algorithm
- JSON
- coding test
- datastructure
- 윤성우 열혈자료구조
- C 언어 코딩 도장
- 메모리구조
- 윤성우의 열혈 자료구조
- 혼자 공부하는 C언어
Archives
- Today
- Total
Engineering Note
[Swagger] Spring Boot 프로젝트 스웨거 연동 본문
Step 1: Swagger 라이브러리 추가 (Spring Boot 3.x)
build.gradle에 추가
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'
Step 2: Swagger 설정 클래스 작성
package com.security.auth.config;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(new Info()
.title("Auth API")
.description("Spring Security & JWT 기반 인증 시스템 API 문서")
.version("v1.0.0"));
}
}
Step 3: 서버 실행 후 접속
스웨거 접속 URL : http://localhost:8080/swagger-ui/index.html
Step 4: 시큐리티 설정이 허용
package com.security.auth.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
public class SecurityConfig {
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf(csrf -> csrf.disable())
.authorizeHttpRequests(auth -> auth
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**", "/swagger-resources/**").permitAll()
.anyRequest().authenticated()
);
return http.build();
}
}
'/**' 은 url 하위 뎁스까지 모두 허용한다는 의미
'Tip' 카테고리의 다른 글
| [Tip] 기술서적 및 기술문서 잘 읽는법(프로그래밍은 운동이다) (2) | 2025.07.26 |
|---|---|
| [IntelliJ] IntelliJ에 spring-dev-tools 적용하기, 환경설정 (2) | 2025.07.04 |
Comments