1.@Autowired注解不可以用在静态属性上: 解决方法: 使用实现了ApplicationContextAware接口的自定义工具类,ApplicationContextAware可以让我们获得spring的上下文对象ApplicationContext,通过ApplicationContext 的getBean方法可以获得指定类的Bean对象.举例如下: @Component public class contextTest implements ApplicationContextAw
有时候报的错误让你匪夷所思,找错误得学会找根.源头在哪里? 比如:我们刚开始看的错误就是 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userInfoServiceImpl': Unsatisfied dependency expressed through field 'userInfoRepository'; nested exception