0

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

https://stackoverflow.com/a/10998044/2182503

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

环境:

  • 雄猫 7
  • JDK 1.7 / JRE7
  • 编译器版本 1.7
  • 春天 3.2.4
  • 方面J 1.7.3
  • Spring 方面 4.0.0

聚甲醛

……

<!-- AspectJ -->
<dependency>
     <groupId>org.aspectj</groupId>
     <artifactId>aspectjrt</artifactId>
     <version>${aspectj.version}</version>
 </dependency>

 <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-aspects</artifactId>
     <version>${spring.aspects.version}</version>
 </dependency>

……

    <build>
    <pluginManagement>
        <plugins>
            <!-- Maven complier plugin that forces maven to use specified version 
                of JDK/JRE while compilation -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${compiler.version}</source>
                    <target>${compiler.version}</target>
                </configuration>
            </plugin>

            <!-- AspectJ Plugin - For dependency injection with new() -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.5</version>
                <configuration>
                    <complianceLevel>1.7</complianceLevel>
                    <encoding>UTF-8</encoding>
                    <aspectLibraries>
                        <aspectLibrary>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-aspects</artifactId>
                        </aspectLibrary>
                    </aspectLibraries>
                    <!-- Xlint set to warning alleviate some issues, such as SPR-6819. 
                        Please consider it as optional. https://jira.springsource.org/browse/SPR-6819 -->
                    <Xlint>warning</Xlint>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Less CSS Plugin -->
            <plugin>
                ...
            </plugin>
        </plugins>
    </pluginManagement>
</build>

网络应用配置:

@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;
}
4

0 回答 0