0

次の解決策を見つけましたが、残念ながら機能させることができません。

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

正常にコンパイルできますが、アプリケーションをテストすると、Spring Bean は常に null になります。

環境:

  • トムキャット7
  • JDK1.7/JRE7
  • コンパイラ バージョン 1.7
  • 春 3.2.4
  • アスペクトJ 1.7.3
  • 春の側面 4.0.0

POM

....

<!-- 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>

WebAppConfig:

@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