aspectj-maven-plugin,声明soft如何编译

是否可以使用软化的exception编译项目(例如: declare soft: Exception : execution(* *.*()); )只使用aspectj-maven-plugin中的方面? 我无法处理它……我仍然遇到编译错误

 unreported exception Exception; must be caught or declared to be thrown 

因此编译时不考虑方面。

我正在使用此命令编译:

 mvn clean aspectj:compile 

我的pom.xml是:

  4.0.0 pl.group.id aop 1.0.0   org.aspectj aspectjrt 1.7.4   org.apache.maven.plugins maven-compiler-plugin 3.1      org.codehaus.mojo aspectj-maven-plugin 1.6  1.7 1.7 1.7 src/main/aspect     compile test-compile        

我究竟做错了什么?

实际上我认为Maven编译器插件3.0和3.1中存在一个错误,因为对我来说它适用于插件版本2.5.1。 似乎增量编译被破坏或者相应的开关useIncrementalCompilation在其含义中以某种方式被意外颠倒,因为它是在3.1中引入的。 有趣的是,将其值设置为false修复我的情况。 降级到2.5.1也是如此。 在这两种情况下,我都需要将AspectJ Maven插件的阶段更改为process-sources ,如用户@Gus链接的问题中所述。

解决方案A:

  4.0.0 de.scrum-master.stackoverflow aspectj-soft-exceptions 1.0-SNAPSHOT  UTF-8 1.8.0  AspectJ sample with declare soft Demonstrates how to build an AspectJ project using "declare soft" with Maven    maven-compiler-plugin 3.1  1.7 1.7  false    org.codehaus.mojo aspectj-maven-plugin 1.6  true 1.7 1.7 ignore 1.7 UTF-8 true     process-sources  compile test-compile      org.aspectj aspectjtools ${aspectj.version}        org.aspectj aspectjrt ${aspectj.version} runtime    

解决方案B:

  4.0.0 de.scrum-master.stackoverflow aspectj-soft-exceptions 1.0-SNAPSHOT  UTF-8 1.8.0  AspectJ sample with declare soft Demonstrates how to build an AspectJ project using "declare soft" with Maven    maven-compiler-plugin  2.5.1  1.7 1.7    org.codehaus.mojo aspectj-maven-plugin 1.6  true 1.7 1.7 ignore 1.7 UTF-8 true     process-sources  compile test-compile      org.aspectj aspectjtools ${aspectj.version}        org.aspectj aspectjrt ${aspectj.version} runtime