ERROR!!!!!!!

๐Ÿ‘ฟ[Spring Error] java.lang.IllegalStateException: No primary or default constructor found for class || @Builder && @NoArgsConstructor

voider 2020. 9. 13. 01:25
java.lang.AssertionError: Request processing failed; nested exception is java.lang.IllegalStateException: No primary or default constructor found for class com.coco.domain.BoardVO
    at org.junit.Assert.fail(Assert.java:89)
    at com.coco.controller.BoardControllerTest.registerTest(BoardControllerTest.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

java.lang.IllegalStateException: No primary or default constructor found for class com.coco.domain.BoardVO

๊ธฐ๋ณธ ์ƒ์„ฑ์ž๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋Š” ์—๋Ÿฌ๋‹ค.
๊ทธ๋ž˜์„œ VOํด๋ž˜์Šค์— Lombok์˜ @NoArgsConstructor๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ธฐ๋ณธ ์ƒ์„ฑ์ž๋ฅผ ๋งŒ๋“ค์–ด์คฌ๋”๋‹ˆ,
@Builder์— ๋นจ๊ฐ„ ์ค„์ด ์ƒ๊ธฐ๋ฉด์„œ The constructor BoardVO(Long, String, String, String, Date, Date) is undefined๋ผ๋Š” ๋ฉ”์„ธ์ง€๊ฐ€ ๋‚˜์™”๋‹ค.
@Builder๋ฅผ ์“ฐ๋ฉด ๋ชจ๋“  ์š”์†Œ๊ฐ€ ํฌํ•จ๋œ ์ƒ์„ฑ์ž๊ฐ€ ํ•จ๊ป˜ ์ƒ์„ฑ๋˜๋Š”๋ฐ, ๊ฑฐ๊ธฐ๋‹ค๊ฐ€ @NoArgs.....๋ฅผ ๋ถ™์ด๋ฉด ๊ทธ ์ƒ์„ฑ์ž๊ฐ€ ๊ธฐ๋ณธ ์ƒ์„ฑ์ž๋กœ ๋ฐ”๋€๋‹ค. ๋”ฐ๋ผ์„œ, ๋นŒ๋”์— ๊ผญ ํ•„์š”ํ•œ ์ƒ์„ฑ์ž๊ฐ€ ์‚ฌ๋ผ์กŒ๋‹ค๋Š” ์—๋Ÿฌ ๋ฉ”์„ธ์ง€๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๊ฒƒ์ด๋‹ค.
@AllArgsConstructor๋„ ํ•จ๊ป˜ ๋ถ™์—ฌ์ฃผ๋ฉด ํ•ด๊ฒฐ๋œ๋‹ค.

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BoardVO {
    private Long bno;
    private String title;
    private String content;
    private String writer;
    private Date regdate;
    private Date moddate;
}