Search code examples
mavenaspectj-maven-plugin

aspectj-maven-plugin can't resolve java.util.stream.*


I'm trying to compile a project I recently upgraded to Java 8.

Now that I'm starting to use Java 8 specific features, I find myself getting exception on the aspectj-maven-plugin. Compilation in Eclipse and normal compilation in Maven works fine.

[ERROR] The import java.util.stream cannot be resolved
/Users/Shared/java/projects/msa/platform/core/src/main/java/nl/project/social/SomeClass.java:6
import java.util.stream.Collectors;

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>1.8.5</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>1.8.5</version>
                </dependency>
            </dependencies>
            <configuration>
                <complianceLevel>1.8</complianceLevel>
                <source>1.8</source>
                <target>1.8</target>
                <verbose>false</verbose>
                <outxml>true</outxml>
                <encoding>UTF-8</encoding>
                <showWeaveInfo>true</showWeaveInfo>
                <forceAjcCompile>true</forceAjcCompile>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
            </configuration>
        </plugin>

I use Spring 4.1.x and jdk1.8.0_31

Any suggestions?


Solution

  • Ok, this was because of a setting in my bash profile which hard wired Java 6 as runtime environment.