Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在使用new关键字创建的对象中自动关联SpringBean_Spring_Maven_New Operator_Autowired_Aspectj Maven Plugin - Fatal编程技术网

在使用new关键字创建的对象中自动关联SpringBean

在使用new关键字创建的对象中自动关联SpringBean,spring,maven,new-operator,autowired,aspectj-maven-plugin,Spring,Maven,New Operator,Autowired,Aspectj Maven Plugin,我找到了以下解决方案,但不幸的是,我无法让它工作 我可以成功编译,但是当我测试应用程序时,我的Springbean总是空的 环境: 雄猫7 JDK1.7/JRE7 编译器版本1.7 春季3.2.4 AspectJ 1.7.3 SpringAspects4.0.0 POM 月份: @Configuration @EnableWebMvc @EnableScheduling @EnableSpringConfigured @PropertySource("classpath:webappli

我找到了以下解决方案,但不幸的是,我无法让它工作

我可以成功编译,但是当我测试应用程序时,我的Springbean总是空的

环境:

  • 雄猫7
  • JDK1.7/JRE7
  • 编译器版本1.7
  • 春季3.2.4
  • AspectJ 1.7.3
  • SpringAspects4.0.0
POM

月份:

@Configuration
@EnableWebMvc
@EnableScheduling
@EnableSpringConfigured
@PropertySource("classpath:webapplication.properties")
@ComponentScan("com.root.package")
public class WebAppConfig extends WebMvcConfigurerAdapter {
 ...
}
public class Month {
     private void fillDaysOfMonth() {  
         ...         
         for (int i = 1; i <= date.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
             Day day = new Day();
             ...
         }
     }    
}
@Configurable
public class Day {

    @Autowired private AbsenceService absenceService;
    @Autowired private HolidayMasterdataService holidayMasterdataService;
}

你是否准备好了课堂上的设置器和获取器,以便自动连线工作?你需要为你计划注入的依赖项准备合适的设置器和获取器。不,它们没有。但是我添加了setter/getter和bean仍然没有被注入。这是@Configurable的一种特殊行为吗?因为如果我在类中自动连接相同的bean(由Spring初始化),我不需要setter/getter。另一个问题:我仍然需要maven编译器插件吗?你的应用程序中有很多手动创建的bean还是只有几个?
public class Month {
     private void fillDaysOfMonth() {  
         ...         
         for (int i = 1; i <= date.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
             Day day = new Day();
             ...
         }
     }    
}
@Configurable
public class Day {

    @Autowired private AbsenceService absenceService;
    @Autowired private HolidayMasterdataService holidayMasterdataService;
}