๐จ Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause ์์ธ!
๊ณ์ ์์ ์ฌ์ง์ฒ๋ผ ๋ฉ์์ง๊ฐ ๋จ๋ฉด์ NullPointException ์ค๋ฅ๊ฐ ๋จ๋๋ฐ ์คํ์๊ฐ ์๋ ์ถ์ด์ ํ๋ํ๋ ๋ค ํ์ธํ์ง๋ง ๊ทธ๋๋ ํด๊ฒฐ์ ๋ชปํ๊ณ ์์๋๋ฐ..
๊ตฌ๊ธ๋งํด๋ณด๋ ๋๋ ๋๊ฐ์ ์ค๋ฅ๊ฐ ๊ณ์ ๋จ๋ ์ฌ๋์ด ์์๊ณ ํด๋น ๊ฒ์๊ธ์ ์ฐธ๊ณ ํด์ ์ค๋ฅ๋ฅผ ํด๊ฒฐํ ์ ์์๋คใ ใ
์ผ๋จ ๊ฒฐ๋ก ์ private final FreeCommentRepository freeCommentRepository; << ์ด๋ final์ ์ ์ด์ฃผ์ง ์์์ ์์กด์ฑ ์ฃผ์ ๊ด๋ จ ๋ฌธ์ ๊ฐ ์๊ธฐ ๋๋ฌธ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ ๊ฒ!
๋ด๊ฐ ๊ฐ์ธ ํ๋ก์ ํธ ๋ธ๋ก๊ทธ์ ์ ๋ฆฌํ๋ฉด์ ์ด ๊ธ์ ์ ์ ๊ฑด๋ฐ
@RequiredArgsConstructor : final์ด๋ @NonNull์ด ๋ถ์ ํ๋์ ์์ฑ์๋ฅผ ์์ฑํด ์ค๋ค. ๋น์ ์์ฑ์๊ฐ 1๊ฐ์ด๊ณ ์์ฑ์์ ํ๋ผ๋ฏธํฐ ํ์ ์ด ๋น์ผ๋ก ๋ฑ๋ก์ด ๊ฐ๋ฅํ๋ค๋ฉด @Autowired ์ด๋ ธํ ์ด์ ์์ด ์์กด์ฑ ์ฃผ์ ์ด ๊ฐ๋ฅํ๋ค.
@RequiredArgsConstructor ์ด๋ ธํ ์ด์ ์ ์ฌ์ฉํ๋ฉด์ final์ ์ ์ด์ฃผ์ง ์์์ ์์กด์ฑ ์ฃผ์ ์ด ์ ๋๋ก ๋์ง ์์ ๊ฒ์ด๋คใ
๐ ํด๊ฒฐ ๋ฐฉ์
๊ทธ๋ฅ ์์ ๋งํ ๊ฒ์ฒ๋ผ final๋ง ์ถ๊ฐํด์ฃผ๋ฉด ๋๋ค ๐
๋๊ธ ๋ฑ๋ก๊น์ง ์ฑ๊ณต!
์์ ์ธ๊ธํ๋ ์ฐธ๊ณ ํ๋ ๋ธ๋ก๊ทธ
https://oh-sh-2134.tistory.com/86
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exc
์ํฉ ํ๋ก์ ํธ ๋์ค post ์์ฒญ ์ดํ ๋ฐ์์ ํ ๋ฌธ์ ์ด๋ค. ๊ตฌ๊ธ๋งํ๊ธฐ์ ์ NullExeption์ด ๋ฐ์ํ ์ ์๋ ๋ถ๋ถ์ ์ฐพ๋๋ฐ ํ๋ฃจ๋ฅผ ๋ณด๋ด๊ณ ...ใ ๊ตฌ๊ธ๋ง์์ ํ์ธ ํ ์์ธ์๋ ์๋์ ๊ฐ์๋ค. ์์ธ Query์
oh-sh-2134.tistory.com
'SpringBoot' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Springboot] swagger ์ ์ฉ ๋ฐ ๋ฐ์ ์ค๋ฅ ์ ๋ฆฌ (0) | 2023.09.20 |
---|---|
[Spring Boot] ๊ฒ์๊ธ ํ์ด์ง ๊ธฐ๋ฒ ์ ๋ฆฌ (0) | 2023.08.22 |
[Spring boot] BCryptPasswordEncoder ์ฌ์ฉํ ๋๋ง๋ค ์ธ์ฝ๋ฉ ๊ฒฐ๊ณผ๊ฐ ๋ฌ๋ผ์ง ๋ (0) | 2023.08.02 |
[Spring boot] ๊ฒ์๊ธ ์์ ๊ธฐ๋ฅ ๊ตฌํํ๋ฉด์ ๋ฐ์ํ ์ค๋ฅ ์ ๋ฆฌ (0) | 2023.07.26 |
[Spring boot] ์ฐ๊ด ๊ด๊ณ ๋งคํ ์ ๋ฆฌ (0) | 2023.07.22 |