当前位置:首页 > 开发 > 系统架构 > 架构 > 正文

Superclass has no null constructors but no arguments were given

发表于: 2014-03-28   作者:alleni123   来源:转载   浏览次数:
摘要: 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
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




 <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上找到原因:
http://stackoverflow.com/questions/13711347/spring-constructor-dependency-injection-issues

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

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
在自己做机房收费系统的过程中出现了这样的一个现象:如图 str1 下面出现了一行波浪线.同时提醒自己
在自己做机房收费系统的过程中出现了这样的一个现象:如图 str1 下面出现了一行波浪线.同时提醒自己
在自己做机房收费系统的过程中出现了这样的一个现象:如图 str1 下面出现了一行波浪线.同时提醒自己
Have you ever faced a situation where you wanted to modify your existing table and was bugged
If I Were Yo选自Tamia2000年发行的专辑《A nu day》 歌曲中一句歌一滴水,歌声水声那样完美的切合
看了第三章前半部分extend作者实现的superclass() 部分,不知道为何在分析extjs源码中途要创造这样
Eclipse 中 program arguments 与 VM arguments 的区别 附代码: public static void main(String[]
今天用控制台新建了一个Maven工程。用eclipse导入这个工程后,index.jsp报了这个错误: The supercl
完整错误信息: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS" AND
转自:http://blog.csdn.net/testcs_dn/article/details/36455669 完整错误信息: THIS SOFTWARE IS
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号