1. 程式人生 > >Failed to instantiate No default constructor found; nested exception is java.lang.NoSuchMethodExcept

Failed to instantiate No default constructor found; nested exception is java.lang.NoSuchMethodExcept

從網頁接受引數,引數多的情況下一般會定義一個類,來裝這些引數,比如UserParam這個類就是裝網頁裡面轉過來的

id、username、telephone等資訊。但是會發現在修改的時候會報如下錯誤。

報錯資訊如下:

org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mmall.param.UserParam]: 
      No default constructor found; nested exception is java.lang.NoSuchMethodException:
      com.mmall.param.UserParam.<init>()

解決辦法:

把UserParam裡面的@Builder註解去掉。

@Getter
@Setter
@Builder   //這裡的@Builder一定要去掉。否則在修改的時候會失敗
public class UserParam {...}