私はScalaで作られたドメインとJavaで作られたいくつかのクラスを持っています。私はAspectjを使っていくつかの側面を作っておく必要があります。なぜなら、Javaクラスではうまくいくからです。 問題は、Scalaクラスに注釈が付けられても機能しないということです。 hibernateのような他の注釈は私のScalaクラスとうまく機能します。スカラ型でaspectjを動作させる
これは私のpom.xmlです:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Group</groupId>
<artifactId>Parent</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.2</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>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>createClassesDir</id>
<phase>process-resources</phase>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}\unwoven-classes" />
<mkdir dir="${project.build.directory}\classes" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>${aspectj.version>}</source>
<target>${aspectj.version>}</target>
<weaveDirectories>
<weaveDirectory>${project.build.directory}\unwoven-classes</weaveDirectory>
</weaveDirectories>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>Aspects</module>
</modules>
</project>
私は側面と、コードの残りの部分は正常に動作しますので、私は、Mavenのに何かをしなければならないと思います。 これはどうしてですか?
ありがとうございました!
ありがとうございました!このソリューションは、私がアップロードしたプロジェクトで完璧に動作します。私は既にプルリクエストを受け入れて、それをマルチモジュールにするため少し変更しました。あなたの忍耐と助けてくれてありがとう! – Motomine
私は最後の質問[ここ](http://stackoverflow.com/questions/43422025/using-aspectj-when-i-run-the-application-with-tomcat)を投稿しました。それは可能ならば??ありがとうございました! – Motomine
これを読んでいる他の人たちのために、@ Motomineのマルチモジュール設定が壊れていて、すべてのテストがMavenで失敗し、IntelliJ IDEAでも失敗しました。私の[フォーク](https://github.com/kriegaex/aspectj-with-scala)にそれを修正し、別のプルリクエストを発行した場合。だから誰かがScala対応のAspectJマルチモジュール設定のショーケースを探しているのであれば、それを見つけることができます。 – kriegaex