为aspectj运行JDK8 [英] Running JDK8 for aspectj

查看:734
本文介绍了为aspectj运行JDK8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JDK8运行aspectj-maven插件。但它给出了像
这样的错误java.lang.CharSequence类型无法解析。它是从所需的.class文件间接引用的

I am trying to run aspectj-maven plugin with JDK8. But it is giving errors like "The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files"

任何帮助如何解决,或者aspectj-maven-plugin是否支持JDK8。我正在使用1.6版本的aspectj - maven-plugin。

Any help on how to resolve, or if the aspectj-maven-plugin supports JDK8. I am using 1.6 version of aspectj--maven-plugin.

推荐答案

我必须达到同样的目的,我开车疯狂试图弄清楚这一点,幸运的是我可以解决它,在这里我告诉你我做了什么:

I had to achieve the same and I drove crazy trying to figure out this, fortunately I could solve it and here I give you what I did:

使用 aspectj-maven-plugin 使用Java 8你需要版本aspectj-maven-plugin 1.7(注意,aspectj-maven-plugin 1.6适用于Java 7)。

To use aspectj-maven-plugin with Java 8 you need version aspectj-maven-plugin 1.7 (Note that aspectj-maven-plugin 1.6 works for Java 7).

所以,maven插件配置需要:

So, the maven plugin configuration needs to be:

        <!-- AspectJ configuration -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.7-SNAPSHOT</version>
            <configuration>
                <complianceLevel>1.8</complianceLevel>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

顺便说一句,所需的aspectJ罐子是:

By the way, the aspectJ jars needed are:

    <!-- Spring AOP + AspectJ -->
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.8.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>1.8.1</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.1</version>
    </dependency>

我遇到的最重要的事情是你需要来手动将aspectj-maven-plugin 1.7 jar安装到你的pom.xml中,因为这个jar还没有在maven repo上。

And the most important thing I've struggled was that you need to install the aspectj-maven-plugin 1.7 jar manually into your pom.xml since this jar aren't on maven repo yet.

你可以从Haus Jira那里得到它(看看在附件部分):

You can get it from Haus Jira (look at the Attachment section):

https://jira.codehaus.org/browse/MASPECTJ-131

顺便说一句,一旦你将它复制到你的仓库,你需要创建你的拥有 aspectj-maven-plugin-1.7-SNAPSHOT.pom 相应目录中的文件。您可以从版本1.6复制它但确保您修改以下内容:

Btw, once you download it an copy it to your repo you need to create your own aspectj-maven-plugin-1.7-SNAPSHOT.pom file within the corresponding directory. You can copy it from version 1.6 BUT ensure you modify the following content:

 <version>1.7-SNAPSHOT</version>

 <properties>
    <aspectjVersion>1.8.1</aspectjVersion>
    <mavenVersion>2.2.1</mavenVersion>
    <changesPluginVersion>2.9</changesPluginVersion>
 </properties>

这就是你要去的地方,希望能提供帮助。

That's all here you go, hope to help.

这篇关于为aspectj运行JDK8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆