spring整合groovy异常:FileNotFoundException

整合了下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配置文件中如下定义时,获取该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.(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.(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的配置方案可以完美运行:,暂不知其所以然,继续研究,吐血而记。







你可能感兴趣的:(SSH,JAVA)