์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- ํด๋ฆฐ์ฝ๋
- ์บ์ฑ
- ํด๋ฆฐ ์ฝ๋
- ๊ฐ์ฒด
- ๊ฐ์ฒด์งํฅ์ ์ฌ์ค๊ณผ ์คํด
- SRP
- JPA
- string
- ์คํ๋ง
- cache
- ์ฑ ์
- ๋ฆฌํฉํ ๋ง
- ์คํ๋ง๋ถํธ
- ์ฟผ๋ฆฌ ์ต์ ํ
- JIT
- ์๋ฐ
- ์บก์ํ
- ์ฌ์ฌ์ฉ์ฑ
- ์ธํฐํ๋ฆฌํฐ
- Lombok
- Java
- ์บ์
- clean code
- REST API
- spring boot
- ๋๋ฉ์ธ ๋ชจ๋ธ
- ์ถ์ํ
- ๊ฐ์ฒด์งํฅ
- ํ๋ ฅ
- Refactor
- Today
- Total
GO SIWOO!
[SpringBoot] MockMvc @Autowired ์๋ฌ ๋ณธ๋ฌธ
๐ ์๋ฌ
์ธํ ๋ฆฌ์ ์ด : Intellij IDEA 2021.2.1
์คํ๋ง๋ถํธ : 3.0.5
์๋ฐ : 17
junit : 5.9.2
Could not autowire. No beans of 'MockMvc' type found.
MockMvc๋ฅผ Spring IoC ์ปจํ ์ด๋์์ ์ฐพ์ ์ ์๋จ๋ค
@AutoConfigureMockMvc๋ฅผ ํตํด MockMvc๋ฅผ ์ฌ์ฉํ ์ ์์ ํ ๋ฐ...
๊ทธ๋ฐ๋ฐ ๋ MockMvc ๊ฐ์ฒด๋ฅผ ํ์ฉํ Test๋ค์ ์ ๋ถ ์ฑ๊ณตํ๊ณ ์๋ค. ํ ์คํธ ์ฑ๊ณต์ ํ์ง๋ง ๋นจ๊ฐ์ค์ด ๋ณดํต ๊ฑฐ์ฌ๋ฆฌ๋๊ฒ ์๋๋ค.
๐ ํด๊ฒฐ์ฑ
intellij Could not autowire. No beans of 'MockMvc' type found. but test is ok
i'm wonder that i can see this error(Could not autowire. No beans of 'MockMvc' type found. ) this is my code import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.
stackoverflow.com
StackOverflow์์ ๋ต์ ์ฐพ์๋ค.
Intellij์ ํ์ ๋ฒ์ ์ ๋ฐ๋ฅธ ๋ฌธ์ ์๊ณ
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
ํด๋น ์ด๋ ธํ ์ด์ (@SuppressWarning)์ ์ถ๊ฐํด ํน์ ์ค๋ฅ ์ง์ ์ ๋ฌด์ํ ์ ์๋ค. ํด๋น ์ด๋ ธํ ์ด์ ์ IDE๋ ์ปดํ์ผ๋ฌ์๊ฒ ํด๋น ์ค๋ฅ ๋ฉ์์ง๋ฅผ ๋ฌด์ํ๋ผ๋ ๊ฒ์ ๋ช ์์ ์ผ๋ก ์๋ ค์ค ๋์ ์ฌ์ฉํ๋ค.
`SpringJavaInjectionPointsAutowiringInspection`์ Intellij IDEA์์ ์ ๊ณตํ๋ ๊ฒฝ๊ณ ๋ฅผ ๋ฌด์ํ๋ค.
์์กด์ฑ ์ฃผ์ ์ ๊ฒ์ฌ ๊ณผ์ ์์ @Autowired ์ด๋ ธํ ์ด์ ์ ์ฌ์ฉํ Spring์์ ๋ฐํ์ ๊ณผ์ ์์ ์์กด์ฑ ์ฃผ์ ์ ๊ฒ์ฌํ๋ค. ๋ฐ๋ผ์ ๋ฐํ์์ ๋ค์ด๊ฐ์ง ๋ชปํ ์ํฉ์์ Intellij IDEA์์ ์ปดํ์ผ ๊ณผ์ ์ ์์กด์ฑ ์ค๋ฅ๋ฅผ ๋ํ๋ธ ๊ฒ์ผ๋ก ๋ณด์ธ๋ค.