๐ป ํ๋ก์ ํธ/๐ ๏ธ ํธ๋ฌ๋ธ์ํ 6 [ ํธ๋ฌ๋ธ ์ํ ] SQLSyntaxErrorException - @SQLDelete ์ฌ์ฉ ์ ํ ์ด๋ธ ์ปฌ๋ผ๋ช ๋ถ์ผ์น ๋ฌธ์ Soft Delete๋ฅผ ๊ตฌํํ๊ธฐ ์ํด Hibernate์ @Where ๋ฐ @SQLDelete ์ด๋ ธํ ์ด์ ์ ์ ์ฉํ์ ๋, ๋ค์๊ณผ ๊ฐ์ SQLSyntaxErrorException์ด ๋ฐ์ํ๋ค.๋ฌธ์ ์ํฉSQLSyntaxErrorException: Unknown column 'member_id' in 'where clause'์ฝ๋ ์์ฑ ๊ณผ์ @Where(clause = "is_deleted = false")@SQLDelete(sql = "UPDATE member SET is_deleted = true WHERE member_id = ?")@Where๋ฅผ ์ฌ์ฉํ์ฌ is_deleted๊ฐ false์ธ ๋ฐ์ดํฐ๋ง ์กฐํํ๋๋ก ์ค์ ํ๋ค.@SQLDelete๋ฅผ ํ์ฉํ์ฌ ์ญ์ ์์ฒญ ์ Soft Delete๋๋๋ก SQL ์ฟผ๋ฆฌ๋ฅผ ์์ฑํ๋ค.. 2025. 2. 4. [ ํธ๋ฌ๋ธ ์ํ ] 403 Forbidden ์๋ฌ์ SecurityContextHolder ๋ฌธ์ ํด๊ฒฐํ๊ธฐ Spring Security๋ฅผ ์ด์ฉํด์ ๊ถํ๋ณ URL ์ ๊ทผ์ ์ค์ ํ๋ ์ค, 403 Forbidden ์๋ฌ๋ฅผ ๋ง์ฃผํ๋ค.๋ฌธ์ ์ํฉ๋ค์๊ณผ ๊ฐ์ด /admin/** ์ /users/** ์ ๋ํ ๊ถํ์ ์ค์ ํ ์ํ์์ ADMIN ๊ณ์ ์ผ๋ก ์ ๊ทผํ ๋ 403 Forbidden ์๋ฌ๊ฐ ๋ฐ์ํ๋ค..requestMatchers("/admin/**").hasRole("ADMIN").requestMatchers("/users/**").hasRole("USER")๋ฌธ์ ์์ธ ๋ถ์JwtFilter์์ ์ธ์ฆ(Authentication)๊ณผ ์ธ๊ฐ(Authorization)๋ฅผ ์ฒ๋ฆฌํ๋ฉด์ ๋ฐ์ํ๋ค.Spring Security๊ฐ ๋ด๋ถ์ ์ผ๋ก SecurityContextHolder๋ฅผ ์ด์ฉํด ์ธ์ฆ ์ ๋ณด๋ฅผ ๊ด๋ฆฌํ๋๋ฐ, JwtFilter์์ Secu.. 2025. 1. 27. [ ํธ๋ฌ๋ธ ์ํ ] The bean 'jwtFilter' could not be registered ์๋ฌ ํด๊ฒฐํ๊ธฐ Spring ํ๋ก์ ํธ๋ฅผ ์งํํ๋ค๋ณด๋ฉด ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๋ฅผ ๋ง์ฃผํ ๋๊ฐ ์๋ค.The bean 'jwtFilter', defined in class path resource [org/example/expert/config/FilterConfig.class], could not be registered. A bean with that name has already been defined in file [/Users/t2023-m0071/IdeaProjects/spring-plus/build/classes/java/main/org/example/expert/config/JwtFilter.class] and overriding is disabled.๋ฌธ์ ์ํฉ์ ์๋ฌ๋ JwtFilter.class์์ ์ด๋ฏธ Bean์ผ.. 2025. 1. 27. [ ํธ๋ฌ๋ธ ์ํ ] ์๋ จ CRUD ๊ธฐ๋ฐ์ ํ ์คํธ, ๊ฐ์ ๊ณผ์ ๊ณผ์ ํธ๋ฌ๋ธ ์ํ ๋ฌธ์ ์ํฉFilter์์ ๋ฐ์ํ๋ ์์ธ๋ฅผ GlobalExceptionHandler๋ฅผ ์ด์ฉํด์ ํด๊ฒฐํ๋ ค๊ณ ํ์ง๋ง, Postman์ ์คํํ์ ๋ 500 Internal Error๊ฐ ๋ฐ์ํ๋ค.๋ฌธ์ ์์ธ@RestControllerAdvice๋ Filter์์ ๋ฐ์ํ ์์ธ๋ฅผ ์ฒ๋ฆฌํ์ง ์๋๋ค.Filter๋ Controller๋ก ์์ฒญ์ด ์ ๋ฌ๋๊ธฐ ์ ์ ์คํ๋๊ธฐ ๋๋ฌธ์, @RestController๋ก ์ฒ๋ฆฌํ ์ ์๋ ์์ญ์ด๋ค.์ด๋ก ์ธํด ์์ธ๋ฅผ ์ฒ๋ฆฌํ์ง ๋ชปํ๊ณ 500 Internal Error๊ฐ ๋ฐํ๋์๋ค.ํด๊ฒฐ ๋ฐฉ๋ฒFilter ๋ด์์ ์ง์ HTTP ์ํ ์ฝ๋์ ์๋ฌ ๋ฉ์์ง๋ฅผ ์ค์ ํด์ ์๋ตํ๋๋ก ์์ ํ๋ค.์์ ๋ ์ฝ๋if (session == null || session.getAttribute("loginM.. 2025. 1. 6. [ ํธ๋ฌ๋ธ ์ํ ]์ผ์ ๊ด๋ฆฌ ์ฑ Develop_ํธ๋ฌ๋ธ ์ํ ๊ณผ์ ํธ๋ฌ๋ธ ์ํ ๋ฌธ์ ์ํฉ์ผ์ ์์ฑ API๋ฅผ ์์ฑํ๊ณ Postman์ผ๋ก ํ ์คํธํ์ง๋ง 500 Internal Server Error๊ฐ ๋ฐ์ํ๋ค.๋ฌธ์ ์์ธ์ฝ๋์์ @EntityListeners ์ด๋ ธํ ์ด์ ์ด ์๋ชป๋ ํด๋์ค๋ฅผ ์ฐธ์กฐํ๊ณ ์์๋ค.์๋ชป๋ ์ฝ๋@EntityListeners(EntityListener.class)์ด๋ก ์ธํด EntityListener๊ฐ ์ ๋๋ก ๋์ํ์ง ์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค.ํด๊ฒฐ ๋ฐฉ๋ฒ@EntityListeners ์ด๋ ธํ ์ด์ ์ ์ฌ๋ฐ๋ฅธ ํด๋์ค์ธ AuditingEntityListener๋ก ์์ ํ๋ค.์์ ๋ ์ฝ๋@EntityListeners(AuditingEntityListener.class)์์ ํ Postman์ผ๋ก ๋ค์ ์์ฒญ์ ๋ณด๋๊ณ , ์ ์์ ์ผ๋ก ์ผ์ ์ด ์์ฑ๋์๋ค.๊ฒฐ๋ก ์ฝ๋๋ฅผ ์์ฑํ ๋ ์ด๋ ธํ ์ด.. 2024. 12. 19. [ ํธ๋ฌ๋ธ ์ํ ]์ผ์ ๊ด๋ฆฌ ์ฑ ๊ณผ์ _ํธ๋ฌ๋ธ ์ํ ๊ณผ์ ํธ๋ฌ๋ธ ์ํ ๋ฌธ์ ์ํฉIntelliJ์์ ์ฝ๋๋ฅผ ์์ฑํ๋ ์ค, import๋ฅผ ์ํํ ๋ ์ฝ๋์ ๋งจ ์๋ก ์ถ๊ฐ๋์ง ์๊ณ ์์ฑ ์ค์ธ ํด๋น ์ค์ import๋ฌธ์ด ์ถ๊ฐ๋๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค.๋ฌธ์ ์์ธ๋ฌธ์ ์ ์ ํํ ์์ธ์ ํ์ ํ์ง ๋ชปํ๋ค.ํ์ง๋ง import ์๋ ์ IntelliJ ์ฐ์ธก ํ๋จ์ IDE Error ๋ฉ์์ง๊ฐ ์ง์์ ์ผ๋ก ๋ํ๋ ๊ฒ์ ๋ณด์ IntelliJ ์์ฒด์ ๋ฌธ์ ๋ก ํ๋จํ๋ค.์ฌ๋ฌ ํ๋ฌ๊ทธ์ธ์ ์ค์นํ๋ ๊ณผ์ ์์ ์ค์ ์ด ๊ผฌ์๊ฑฐ๋ ์๋ชป๋ ๋ณ๊ฒฝ์ด ์ด๋ฃจ์ด์ง ๊ฒ์ผ๋ก ์๊ฐํ๊ณ ์๋ค.ํด๊ฒฐ ๋ฐฉ๋ฒํํฐ๋๊ณผ ํจ๊ป ๋ค์ํ ์๋IntelliJ ์ค์ ๋ณ๊ฒฝ์บ์ ์ญ์ ๊ทธ๋ฌ๋ ์ฌ๋ฌ ๋ฐฉ๋ฒ์ ์๋ํด๋ ์ฌ์ ์น IDE Error ๋ฉ์์ง๊ฐ ๋ฐ์ํ์ฌ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง ๋ชปํ๋ค.์ต์ข ํด๊ฒฐIntelliJ๋ฅผ ์์ ํ ์ญ์ ํ ํ ์ฌ์ค์น ์งํ์ฌ์ค์น ํ ๊ธฐ๋ณธ.. 2024. 12. 10. ์ด์ 1 ๋ค์