Error creating bean with name 'pictureServiceImpl': Injection of autowired dependencies failed;
程序员文章站
2024-02-21 23:33:52
...
用SpringMVC的MultipartFile上传文件时出现这个错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pictureServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.taotao.service.impl.PictureServiceImpl.FTP_HOST; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'FTP_HOST' in string value "${FTP_HOST}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
由错误可以看出是注入properties文件出错,后来把配置文件
<context:property-placeholder location="classpath:jdbc.properties"/>
<context:property-placeholder location="classpath:ftp.properties"/>
改成
<context:property-placeholder location="classpath:jdbc.properties,classpath:ftp.properties"/>
完美解决问题
推荐阅读
-
Error creating bean with name ‘XXXController’: Injection of resource dependencies failed
-
bean依赖注入错误:Error creating bean with name 'itemService': Injection of autowired dependencies failed
-
Error creating bean with name 'serverImpl': Injection of autowired dependencies failed;
-
Error creating bean with name ‘userServiceImpl’: Injection of resource dependencies failed
-
Error creating bean with name 'pictureServiceImpl': Injection of autowired dependencies failed;
-
Error creating bean with name 'xxxService': Injection of resource dependencies failed