zoukankan      html  css  js  c++  java
  • struts2的action中@Autowired注入为null的解决方案

    今天遇到类似问题,记录下来以便以后查阅:
    @Aspect作用于action,致使action中的@Autowired注入为null的解决方案,以下三种任选一种:
    1、去掉@Autowired,改用set,get注入
    2、将action纳入spring的ioc管理(struts.objectFactory = org.apache.struts2.spring.StrutsSpringObjectFactory)
    3、修改Struts.xml文件的属性,使自动注入总是有效

    Tip:必须在所有使用了dao的地方,包括调用它的servcie都要进行@Autowired注入,否则之后的注入就会失败..

  • 相关阅读:
    非空约束
    leetcode208
    leetcode207
    leetcode395
    leetcode116
    leetcode105
    leetcode131
    leetcode73
    leetcode200
    leetcode17
  • 原文地址:https://www.cnblogs.com/jpfss/p/7444916.html
Copyright © 2011-2022 走看看