在自动注入的时候报错Could not autowire. No beans of ‘Environment‘ type found.

是因为导错包
本来因该是:
import org.springframework.core.env.Environment;
我导成了:
import org.omg.CORBA.Environment;
导致了自动注入Environment始终不成功
就是导入了也没有getProperty()这个方法
所以切记不要到错包,还有就是自动注入报错的话还可以去找你的类是否在IOC容器里面(@Component)。

猜你喜欢

转载自blog.csdn.net/qq_49249150/article/details/109028615