---
title: "Spring CGlib Superclass has no null constructors but no arguments were given"
author: "crabdave"
date: "2017-07-10T14:48:08Z"
tags: []
categories: ["开源软件"]
slug: "spring-cglib-superclass-has-no-null-constructors-but-no-arguments-were-given"
draft: false
lastmod: "2017-07-10T14:54:14Z"
id: 2383875
url: "https://crabdave.iteye.com/blog/2383875"
---

**Spring CGlib** **Superclass has no null constructors but no arguments were given**

 

 &lt;bean id="beanId" class="com.bean.BeanId"&gt;

        &lt;!--构造器参数--&gt;

        &lt;constructor-arg value="BeanId"/&gt;

 

出现Superclass has no null constructors but no arguments were given异常

 

 

改成属性注入

 

 &lt;bean id="beanId" class="com.bean.BeanId"&gt;

        &lt;!--构造器参数--&gt;

        &lt;property name="name" value="BeanId"/&gt;

 

 

**或者**

创建参数为空的默认构造函数。

 

 

CGlib has one important restriction: the target class must provide a default constructor.

If you use property-based injection instead of constructor-based injection, the problem will go away.

 

**or**

 

I just created an empty default constructor to deal with this.

 

参考：

[https://stackoverflow.com/questions/15223297/superclass-has-no-null-constructors-but-no-arguments-were-given](https://stackoverflow.com/questions/15223297/superclass-has-no-null-constructors-but-no-arguments-were-given)