简体   繁体   English

IntelliJ ApectJ 后编译时编织

[英]IntelliJ ApectJ post-compile time weaving

I have the following aspect:我有以下几个方面:

@Aspect
public class DefaultStringAspect {

    @Around(value = "execution(* org.apache.commons.lang3.StringUtils.defaultString(..))")
    public Object defaultString(ProceedingJoinPoint pjp) {
        return "DEF";
    }  
}

This aspect is applied to a classpath library.这方面应用于类路径库。 It works fine with maven configuration below:它适用于以下 Maven 配置:

           <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                ..
                <configuration>
                   ..
                    <weaveDependencies>
                        <weaveDependency>
                            <groupId>org.apache.commons</groupId>
                            <artifactId>commons-lang3</artifactId>
                        </weaveDependency>
                    </weaveDependencies>
                </configuration>
            </plugin>

When I try to build the project from IntelliJ IDEA, the aspect is not applied.当我尝试从 IntelliJ IDEA 构建项目时,未应用该方面。 The aspect itself is compiled, but woven dependencies are not.方面本身已编译,但编织依赖项未编译。 I've tried to adjust ajc command line options taken from maven's debug output and add them to IntelliJ:我试图调整从 maven 的调试输出中获取的ajc命令行选项并将它们添加到 IntelliJ:

-showWeaveInfo -verbose -classpath ... -inpath ... -d ... -showWeaveInfo -verbose -classpath ... -inpath ... -d ...

but this didn't work for me.但这对我不起作用。 Any other ideas how to force IntelliJ to use the same ajc configuration as maven?任何其他想法如何强制 IntelliJ 使用与 maven 相同的ajc配置?

Delegate IDE build/run actions to Maven as a workaround (File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner):将 IDE 构建/运行操作委托给 Maven 作为解决方法(文件 | 设置 | 构建、执行、部署 | 构建工具 | Maven | Runner):

代表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM