我是靠谱客的博主 聪慧铃铛,最近开发中收集的这篇文章主要介绍Superclass has no null constructors but no arguments were given,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
[color=red]org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.lj.cms.service.IndexService]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
Caused by:
java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given[/color]
<aop:config>
<aop:aspect ref="indexService">
<aop:pointcut id="generateTopPoint"
expression="execution(* com.lj.cms.service.ChannelService.add*(..))||
execution(* com.lj.cms.service.ChannelService.delete*(..))||
execution(* com.lj.cms.service.ChannelService.update*(..))"/>
<aop:after method="generateTop" pointcut-ref="generateTopPoint"/>
</aop:aspect>
</aop:config>
<bean id="ftlPath" class="java.lang.String">
<constructor-arg value="/ftl"></constructor-arg>
</bean>
<bean id="outPath" class="java.lang.String">
<constructor-arg value="/jsp/template"></constructor-arg>
</bean>
@Autowired(required=true)
public IndexService(String ftlPath,String outPath)
{
if(util==null){
this.outPath = outPath;
util=FreemarkerUtil.getInstance(ftlPath);//ftlPath在beans.xml中配置了依赖注入,值为/ftl
}
}
上述代码原本运行时是没有错误的。
后来因为需求把 <aop:config> 的内容去掉了。
结果就一直报如上错误。
弄了半天, 最后在stackoverflow上找到原因:
[url]http://stackoverflow.com/questions/13711347/spring-constructor-dependency-injection-issues[/url]
Classes to be proxied by CGLIB (for AOP support) must have no-args constructors.
These no-args constructors don't have to be public and it doesn't affect anything else - you can use other constructors as usually:
因此只要加入
public IndexService()
{
}
问题就解决了。
最后
以上就是聪慧铃铛为你收集整理的Superclass has no null constructors but no arguments were given的全部内容,希望文章能够帮你解决Superclass has no null constructors but no arguments were given所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复