spring整合groovy异常:FileNotFoundException

4 篇文章 0 订阅

整合了下spring+groovy,myeclipse环境,spring3,groovy2,按照http://groovy.codehaus.org/Dynamic+language+beans+in+Spring以及http://docs.spring.io/spring/docs/2.0.x/reference/dynamic-language.html的步骤,蓦然发现:当在spring配置文件中如下定义时<lang:groovy script-source="classpath:xx/xx/xxx.groovy"></lang:groovy>,获取该xxx bean必然失败,异常如下:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'country3': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'country3': Could not determine scripted object type for GroovyScriptFactory: script source locator [classpath:com/study/test/services/test2Service/impl/NewZealand.groovy]; nested exception is java.io.FileNotFoundException: class path resource [com/study/test/services/test2Service/impl/NewZealand.groovy] cannot be opened because it does not exist

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:454)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at test1.T1.main(T1.java:16)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'country3': Could not determine scripted object type for GroovyScriptFactory: script source locator [classpath:com/study/test/services/test2Service/impl/NewZealand.groovy]; nested exception is java.io.FileNotFoundException: class path resource [com/study/test/services/test2Service/impl/NewZealand.groovy] cannot be opened because it does not exist
    at org.springframework.scripting.support.ScriptFactoryPostProcessor.postProcessBeforeInstantiation(ScriptFactoryPostProcessor.java:307)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:890)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:862)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:448)
    ... 10 more
Caused by: java.io.FileNotFoundException: class path resource [com/study/test/services/test2Service/impl/NewZealand.groovy] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
    at org.springframework.scripting.support.ResourceScriptSource.getScriptAsString(ResourceScriptSource.java:82)
    at org.springframework.scripting.groovy.GroovyScriptFactory.getScriptedObjectType(GroovyScriptFactory.java:200)
    at org.springframework.scripting.support.ScriptFactoryPostProcessor.postProcessBeforeInstantiation(ScriptFactoryPostProcessor.java:301)
    ... 13 more


百思不得其解,遍寻baidu,google,在stackoverflow上有个哥哥说http://stackoverflow.com/questions/5175114/groovy-spring-bean-classpath,果断更改测试了下,无果,郁闷半天,突然发现在spring配置文件中使用配置java bean的配置方案可以完美运行:<bean class="xx.xx.xxx"></bean>,暂不知其所以然,继续研究,吐血而记。







  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值