2017-04-06 12 views
1

私はAspectjでAOPを実行しようとしていますが、なぜ私のアスペクトを実行していないのか分かりません。私はこれを初めて行うのですから、私は間違ったことをしているかもしれません。AspectJのアドバイスは、Mavenのマルチモジュール設定で起動しません。

これは私のコードです:

アスペクト比:

@Aspect 
public class YourAspect { 

    @Pointcut("@annotation(yourAnnotationVariableName)") 
    public void annotationPointCutDefinition(YourAnnotation yourAnnotationVariableName){ 
    } 

    @Pointcut("execution(* *(..))") 
    public void atExecution(){} 

    @Around("annotationPointCutDefinition(yourAnnotationVariableName) && atExecution()") 
    public Object aroundAdvice(ProceedingJoinPoint joinPoint, YourAnnotation yourAnnotationVariableName) throws Throwable { 
     if(yourAnnotationVariableName.isRun()) { 
      Object returnObject = null; 

      try { 
       System.out.println("aspects.YourAspect's aroundAdvice's body is now executed Before yourMethodAround is called."); 
       returnObject = joinPoint.proceed(); 
      } catch (Throwable throwable) { 
       throw throwable; 
      } finally { 
       System.out.println("aspects.YourAspect's aroundAdvice's body is now executed After yourMethodAround is called."); 
      } 
      return returnObject; 
     } 
     return joinPoint.proceed(); 
    } 

    @After("annotationPointCutDefinition(yourAnnotationVariableName) && atExecution()") 
    public void printNewLine(JoinPoint pointcut, YourAnnotation yourAnnotationVariableName){ 
     System.out.print("End\n\r"); 
    } 
} 

注釈:

@Retention(RetentionPolicy.RUNTIME) 
@Target(ElementType.METHOD) 
public @interface YourAnnotation { 
    public boolean isRun() default true; 
} 

メインクラス:

public class MainClass{ 
    public static void main(String[] args) { 
     MainClass yourClass = new MainClass(); 
     yourClass.yourMethodAround(); 
    } 

    @YourAnnotation 
    public void yourMethodAround(){ 
     System.out.println("Executing TestTarget.yourMethodAround()"); 
    } 
} 

私は2つで働いていますモジュール、POMsこのようなKS:

アスペクトのPOM:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

     <groupId>Group</groupId> 
     <artifactId>Aspects</artifactId> 
     <version>1.0-SNAPSHOT</version> 

     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>aspectj-maven-plugin</artifactId> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
       </plugin> 
      </plugins> 
     </build> 

     <dependencies> 
      <dependency> 
       <groupId>org.aspectj</groupId> 
       <artifactId>aspectjweaver</artifactId> 
       <version>1.8.10</version> 
      </dependency> 
     </dependencies> 

    </project> 

主なPOM:

<?xml version="1.0" encoding="UTF-8"?> 
    <project xmlns="http://maven.apache.org/POM/4.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
     <modelVersion>4.0.0</modelVersion> 
    <groupId>Group</groupId> 
    <artifactId>Main</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>aspectj-maven-plugin</artifactId> 
        <version>1.7</version> 
        <configuration> 
         <complianceLevel>1.8</complianceLevel> 
         <source>1.8</source> 
         <target>1.8</target> 
         <aspectLibraries> 
          <aspectLibrary> 
           <groupId>Group</groupId> 
           <artifactId>Aspects</artifactId> 
          </aspectLibrary> 
         </aspectLibraries> 
        </configuration> 
        <executions> 
         <execution> 
          <goals> 
           <goal>compile</goal> 
           <goal>test-compile</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 
       <plugin> 
        <artifactId>maven-assembly-plugin</artifactId> 
        <version>2.5.5</version> 
        <configuration> 
         <appendAssemblyId>false</appendAssemblyId> 
         <descriptorRefs> 
          <descriptorRef>jar-with-dependencies</descriptorRef> 
         </descriptorRefs> 
         <archive> 
          <manifest> 
           <mainClass>aspects.MainClass</mainClass> 
          </manifest> 
         </archive> 
        </configuration> 
        <executions> 
         <execution> 
          <id>a-make-assembly</id> 
          <phase>package</phase> 
          <goals> 
           <goal>single</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.2.1</version> 
       <configuration> 
        <mainClass>aspects.MainClass</mainClass> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <dependency> 
      <groupId>Group</groupId> 
      <artifactId>Aspects</artifactId> 
      <version>1.0-SNAPSHOT</version> 
     </dependency> 
    </dependencies> 
</project> 

私はMVNクリーンMVNのexecその後、両方のプロジェクトにインストールしました:メインプロジェクトでJava、およびそれだけアスペクトではなくメソッドを実行します。誰でも助けてくれますか?

ありがとうございました!

+0

文字通りあなたのポイントカットで 'yourAnnotationVariableName'を使用していますか?パラメータとして注釈タイプが必要です。https://blog.jayway.com/2015/09/08/defining-pointcuts-by-annotations/ –

+0

私はそのWebページに従いました。私のpointcutでyourAnnotationVariableNameを使うのはどういう意味ですか?あなたはもう少し説明できますか? – Motomine

+0

一般的なMavenマルチモジュールプロジェクトや、特にAspectJ Mavenプラグインの使い方には、いくつかの問題と誤った仮定があります。たとえば、アスペクトモジュールはプラグインのバージョンを構成しませんが、メインモジュールを親として使用しません。たとえアスペクトモジュールがメインとメインに依存している場合は、依存関係としてのアスペクトがあるため、これはコンパイルできないため、循環参照を意味します。私はあなたが共通の親を作成してから、正しい構成のアプリケーションとアスペクトモジュールを作成することをお勧めします(私はあなたにそれを手助けすることができます)。 – kriegaex

答えて

0

ここに行ってください。私は可能な限りシンプルにするために、異なるプロジェクト/パッケージで物を分割しませんでした。

プロジェクトのpom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>Group</groupId> 
    <artifactId>Main</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <dependencies> 
     <dependency> 
      <groupId>org.aspectj</groupId> 
      <artifactId>aspectjweaver</artifactId> 
      <version>1.8.10</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 

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

      <plugin> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <configuration> 
        <archive> 
         <manifest> 
          <addClasspath>true</addClasspath> 
          <mainClass>yourpackage.AspectJRawTest</mainClass> 
         </manifest> 
        </archive> 
        <descriptorRefs> 
         <descriptorRef>jar-with-dependencies</descriptorRef> 
        </descriptorRefs> 
       </configuration> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>single</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

     </plugins> 

    </build> 
</project> 

注釈(あなたは正しくこれを書いた):前に注釈を付けた方法で実行されます

package yourpackage; 

import java.lang.annotation.ElementType; 
import java.lang.annotation.Retention; 
import java.lang.annotation.RetentionPolicy; 
import java.lang.annotation.Target; 

@Retention(RetentionPolicy.RUNTIME) 
@Target(ElementType.METHOD) 
public @interface MyCustomAnnotation { 
    public boolean isRun() default true; 
} 

カスタムアドバイス。私はMavenのでそれを構築

package yourpackage; 

public class AspectJRawTest { 

    public static void main(String[] args) { 
     System.out.println("custom annotation playground"); 

     ISomething something = new SomethingImpl(); 

     something.annotatedMethod(); 
     something.notAnnotatedMethod(); 
    } 

} 

interface ISomething { 
    void annotatedMethod(); 

    void notAnnotatedMethod(); 
} 

class SomethingImpl implements ISomething { 
    @MyCustomAnnotation 
    public void annotatedMethod() { 
     System.out.println("I am annotated and something must be printed by an advice above."); 
    } 

    public void notAnnotatedMethod() { 
     System.out.println("I am not annotated and I will not get any special treatment."); 
    } 
} 

:私はこの1つについて確認していない、専門用語は私には全く明らかではない...しかし、:)

package yourpackage; 

import org.aspectj.lang.JoinPoint; 
import org.aspectj.lang.annotation.Aspect; 
import org.aspectj.lang.annotation.Before; 

@Aspect 
public class MyCustomAspect { 
    @Before("execution(* *.*(..)) && @annotation(MyCustomAnnotation)") 
    public void advice(JoinPoint joinPoint) { 
     System.out.printf("BINGO! advice() called before '%s'%n", joinPoint); 
    } 
} 

を動作しているようです最後に、メインクラスこのように:mvn clean compile assembly:single依存関係を含む実行可能なjarを作成する。その後、実行します。

java -jar target/Main-1.0-SNAPSHOT-jar-with-dependencies.jar 
custom annotation playground 
BINGO! advice() called before 'execution(void yourpackage.SomethingImpl.annotatedMethod())' 
I am annotated and something must be printed by an advice above. 
I am not annotated and I will not get any special treatment. 

を、私はどこか、後で完全なプロジェクトをアップロードして、あなたのためのa linkを提供しますが、私が投稿したことは十分なものでなければならないだろう。

私はこれをIDEAでテストしましたが、私のために適切な製織を行うように構成できませんでした(他のIDEの名前も同じです)。しかし、私は今はこれのための時間がありません、あなたは自分でその仕事に対処しなければならないでしょう。良いニュース、それはすべてが裸の骨と働くので可能でなければなりません。

1

ここにはマルチモジュールソリューションがあります。

メインPOM(他のすべての親):

ここでは、基本的な構成ですべてのプラグインを定義する(より具体的な構成は、「アプリケーション」モジュールに記載されています)と、すべての依存関係のバージョンを管理。

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>de.scrum-master.stackoverflow</groupId> 
    <artifactId>main</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <java.source-target.version>1.8</java.source-target.version> 
    <aspectj.version>1.8.10</aspectj.version> 
    </properties> 

    <build> 
    <pluginManagement> 
     <plugins> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.6.1</version> 
      <configuration> 
      <source>${java.source-target.version}</source> 
      <target>${java.source-target.version}</target> 
      <!-- IMPORTANT --> 
      <useIncrementalCompilation>false</useIncrementalCompilation> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>aspectj-maven-plugin</artifactId> 
      <version>1.10</version> 
      <configuration> 
      <!--<showWeaveInfo>true</showWeaveInfo> --> 
      <source>${java.source-target.version}</source> 
      <target>${java.source-target.version}</target> 
      <Xlint>ignore</Xlint> 
      <complianceLevel>${java.source-target.version}</complianceLevel> 
      <encoding>${project.build.sourceEncoding}</encoding> 
      <!--<verbose>true</verbose> --> 
      <!--<warn>constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedArguments,unusedImport</warn> --> 
      </configuration> 
      <executions> 
      <execution> 
       <!-- IMPORTANT --> 
       <phase>process-sources</phase> 
       <goals> 
       <goal>compile</goal> 
       <goal>test-compile</goal> 
       </goals> 
      </execution> 
      </executions> 
      <dependencies> 
      <dependency> 
       <groupId>org.aspectj</groupId> 
       <artifactId>aspectjtools</artifactId> 
       <version>${aspectj.version}</version> 
      </dependency> 
      <dependency> 
       <groupId>org.aspectj</groupId> 
       <artifactId>aspectjweaver</artifactId> 
       <version>${aspectj.version}</version> 
      </dependency> 
      </dependencies> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.5.5</version> 
      <configuration> 
      <appendAssemblyId>false</appendAssemblyId> 
      <descriptorRefs> 
       <descriptorRef>jar-with-dependencies</descriptorRef> 
      </descriptorRefs> 
      </configuration> 
      <executions> 
      <execution> 
       <id>a-make-assembly</id> 
       <phase>package</phase> 
       <goals> 
       <goal>single</goal> 
       </goals> 
      </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.5.0</version> 
     </plugin> 

     </plugins> 
    </pluginManagement> 

    </build> 

    <dependencyManagement> 
    <dependencies> 
     <dependency> 
     <groupId>org.aspectj</groupId> 
     <artifactId>aspectjrt</artifactId> 
     <version>${aspectj.version}</version> 
     </dependency> 
     <dependency> 
     <groupId>de.scrum-master.stackoverflow</groupId> 
     <artifactId>common</artifactId> 
     <version>1.0-SNAPSHOT</version> 
     </dependency> 
     <dependency> 
     <groupId>de.scrum-master.stackoverflow</groupId> 
     <artifactId>aspect</artifactId> 
     <version>1.0-SNAPSHOT</version> 
     </dependency> 
    </dependencies> 
    </dependencyManagement> 

    <modules> 
    <module>common</module> 
    <module>application</module> 
    <module>aspect</module> 
    </modules> 

</project> 

モジュール「共通」:

このモジュールは、より具体的にTOUTの場合は「アプリケーション」と「アスペクト」の両方によって使用されるコード、注釈クラスを含みます。

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
    <groupId>de.scrum-master.stackoverflow</groupId> 
    <artifactId>main</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>common</artifactId> 

</project> 
package de.scrum_master.common; 

import java.lang.annotation.ElementType; 
import java.lang.annotation.Retention; 
import java.lang.annotation.RetentionPolicy; 
import java.lang.annotation.Target; 

@Retention(RetentionPolicy.RUNTIME) 
@Target(ElementType.METHOD) 
public @interface YourAnnotation { 
    boolean isRun() default true; 
} 

モジュール "アスペクト":

は、ここでは単にアスペクトコードを持っています。

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
    <groupId>de.scrum-master.stackoverflow</groupId> 
    <artifactId>main</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>aspect</artifactId> 

    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>aspectj-maven-plugin</artifactId> 
     </plugin> 
    </plugins> 
    </build> 

    <dependencies> 
    <dependency> 
     <groupId>org.aspectj</groupId> 
     <artifactId>aspectjrt</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>de.scrum-master.stackoverflow</groupId> 
     <artifactId>common</artifactId> 
    </dependency> 
    </dependencies> 

</project> 
package de.scrum_master.aspect; 

import de.scrum_master.common.YourAnnotation; 
import org.aspectj.lang.ProceedingJoinPoint; 
import org.aspectj.lang.annotation.Around; 
import org.aspectj.lang.annotation.Aspect; 
import org.aspectj.lang.annotation.Pointcut; 

@Aspect 
public class YourAspect { 
    @Pointcut("@annotation(yourAnnotationVariableName)") 
    public void annotationPointCutDefinition(YourAnnotation yourAnnotationVariableName) { 
    } 

    @Pointcut("execution(* *(..))") 
    public void atExecution() { 
    } 

    @Around("annotationPointCutDefinition(yourAnnotationVariableName) && atExecution()") 
    public Object aroundAdvice(ProceedingJoinPoint thisJoinPoint, YourAnnotation yourAnnotationVariableName) throws Throwable { 
    if (yourAnnotationVariableName.isRun()) { 
     Object result; 
     try { 
     System.out.println("Before " + thisJoinPoint); 
     result = thisJoinPoint.proceed(); 
     } catch (Throwable t) { 
     throw t; 
     } finally { 
     System.out.println("After " + thisJoinPoint); 
     } 
     return result; 
    } 
    return thisJoinPoint.proceed(); 
    } 
} 

モジュール "アプリケーション":

このモジュールは、アプリケーション・コードが含まれています。これは、Exec MavenとMaven Assemblyプラグインの両方を設定します。さらにAspectJ Mavenのアスペクトライブラリとしての "aspect"モジュールを定義しています。

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
    <groupId>de.scrum-master.stackoverflow</groupId> 
    <artifactId>main</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>application</artifactId> 

    <build> 
    <plugins> 

     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-assembly-plugin</artifactId> 
     <configuration> 
      <archive> 
      <manifest> 
       <addClasspath>true</addClasspath> 
       <mainClass>de.scrum_master.app.MainClass</mainClass> 
      </manifest> 
      </archive> 
     </configuration> 
     </plugin> 

     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>exec-maven-plugin</artifactId> 
     <configuration> 
      <mainClass>de.scrum_master.app.MainClass</mainClass> 
     </configuration> 
     </plugin> 

     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>aspectj-maven-plugin</artifactId> 
     <configuration> 
      <aspectLibraries> 
      <aspectLibrary> 
       <groupId>de.scrum-master.stackoverflow</groupId> 
       <artifactId>aspect</artifactId> 
      </aspectLibrary> 
      </aspectLibraries> 
     </configuration> 
     </plugin> 

    </plugins> 
    </build> 

    <dependencies> 
    <dependency> 
     <groupId>de.scrum-master.stackoverflow</groupId> 
     <artifactId>common</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>de.scrum-master.stackoverflow</groupId> 
     <artifactId>aspect</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.aspectj</groupId> 
     <artifactId>aspectjrt</artifactId> 
    </dependency> 
    </dependencies> 
</project> 
package de.scrum_master.app; 

import de.scrum_master.common.YourAnnotation; 

public class MainClass { 
    public static void main(String[] args) { 
    MainClass yourClass = new MainClass(); 
    yourClass.yourMethodAround(); 
    } 

    @YourAnnotation 
    public void yourMethodAround() { 
    System.out.println("Executing TestTarget.yourMethodAround()"); 
    } 
} 

ビルドログ:

[email protected] MINGW64 ~/Documents/java-src/SO_AJ_MavenMultiModuleProblem 
$ mvn clean install 

(...) 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Summary: 
[INFO] 
[INFO] main ............................................... SUCCESS [ 0.241 s] 
[INFO] common ............................................. SUCCESS [ 0.970 s] 
[INFO] aspect ............................................. SUCCESS [ 1.058 s] 
[INFO] application ........................................ SUCCESS [ 0.607 s] 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3.111 s 
[INFO] Finished at: 2017-04-07T17:15:39+02:00 
[INFO] Final Memory: 23M/378M 
[INFO] ------------------------------------------------------------------------ 

実行ログ:

[email protected] MINGW64 ~/Documents/java-src/SO_AJ_MavenMultiModuleProblem 
$ cd application/ 

[email protected] MINGW64 ~/Documents/java-src/SO_AJ_MavenMultiModuleProblem/application 
$ mvn exec:java 
(...) 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building application 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- exec-maven-plugin:1.5.0:java (default-cli) @ application --- 
Before execution(void de.scrum_master.app.MainClass.yourMethodAround()) 
Executing TestTarget.yourMethodAround() 
After execution(void de.scrum_master.app.MainClass.yourMethodAround()) 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
(...) 

[email protected] MINGW64 ~/Documents/java-src/SO_AJ_MavenMultiModuleProblem/application 
$ java -jar target/application-1.0-SNAPSHOT.jar 
Before execution(void de.scrum_master.app.MainClass.yourMethodAround()) 
Executing TestTarget.yourMethodAround() 
After execution(void de.scrum_master.app.MainClass.yourMethodAround()) 

更新:サンプルプロジェクト全体をGitHub repositoryにプッシュしました。

+0

それは良い解決策です!私はしばらくそれを試してみるでしょう。私はこれをやってみたいですが、私は親pom上でmvn clean isntallを実行し、それらのすべてがコンパイルされているということです。しかし、私のモジュールの1つが異なるプロファイルを持っているとどうなりますか?その場合、どうすれば指定できますか?今私はmvnクリーンインストール-Pprofileを行うが、この場合、私は親ではなく、子供の中で実行します。 ありがとうございました! – Motomine

+0

私はその質問を理解していません。 '-Pprofile'でメインビルドを実行すると、そのプロファイルが存在するすべてのモジュールにプロファイルが適用されます。 – kriegaex

+0

私はそれを知らなかった。プロファイルは1つのモジュールにのみ存在し、他のモジュールには存在しないためです。私はこれの背後にトリックがあると思った。私はそれを試してみます !ありがとうございました! – Motomine

関連する問題