相关疑难解决方法(0)

Spring是否要求所有bean都有默认构造函数?

我不想为我的auditRecord类创建默认构造函数.

但是Spring似乎坚持这样做:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'auditRecord' defined in ServletContext resource
[/WEB-INF/applicationContext.xml]: 
Instantiation of bean failed; 
nested exception is org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [com.bartholem.AuditRecord]: 
No default constructor found; 
nested exception is 
java.security.PrivilegedActionException:
java.lang.NoSuchMethodException: 
com.bartholem.AuditRecord
Run Code Online (Sandbox Code Playgroud)

这真的有必要吗?

java spring spring-mvc default-constructor

25
推荐指数
3
解决办法
5万
查看次数

标签 统计

default-constructor ×1

java ×1

spring ×1

spring-mvc ×1