๐Ÿšง

[spring] not initialized in the default constructor ์—๋Ÿฌ

purpplee 2021. 12. 21. 10:25

JUnit ํ…Œ์ŠคํŠธ ์ค‘์— ์•„๋ž˜์ฒ˜๋Ÿผ ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค.

error: variable name not initialized in the default constructor
    private final String name;

 

์ด์œ ๋Š” gradle ๋ฒ„์ „์ด 5๋กœ ์˜ฌ๋ผ๊ฐ€๋ฉด์„œ lombok ์„ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ๋‹ฌ๋ผ์กŒ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์•„๋ž˜์ฒ˜๋Ÿผ ์ˆ˜์ •ํ•ด์ฃผ๋ฉด ํ•ด๊ฒฐ๋œ๋‹ค.

dependencies {
	...
	//gradle ์ด ๋ฒ„์ „ 4 ๋ผ๋ฉด
    implementation 'org.projectlombok:lombok'
    
    //gradle ์ด ๋ฒ„์ „ 5 ๋ผ๋ฉด
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
	...
}
๋ฐ˜์‘ํ˜•