@Entityで指摘されたクラスのセッターが呼び出される前にメソッドを実行しようとしています。 は、だから私は今では、このコードを持っている:インタフェースを持たないクラスでAspectJが動作しない
@Component
@Aspect
public class Observable {
@Before("execution(* br.com.persistence.Transaction.setStatus(..))")
public void beforeSetStatus(JoinPoint joinPoint) {
System.out.println(joinPoint.getSignature().getName());
}
}
私のpom.xml:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<complianceLevel>1.6</complianceLevel>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.5</version>
</dependency>
</dependencies>
</plugin>
そしてspring.xmlに私が追加:
<aop:aspectj-autoproxy proxy-target-class="true"/>
私はインターフェイスをポイントカットしようとした場合それは正しく動作しますが、永続性のあるクラスでは動作しません。インターフェイスを実装していないか、@Entity注釈が原因で問題が発生しているかどうかはわかりません。
上記の設定では、Spring AOPと__not__ AspectJを使用していることに注意してください。 –
Spring AOPで私が欲しいものを達成することはできますか?インターフェイスなしでクラスをポイントカットするには? –
Spring AOPはSpring管理Beanにのみ適用されます。私は、あなたが何を側面に適用しようとしているのか分かりません。説明のためにこの質問を参照してください。http://stackoverflow.com/q/1606559/2699901 –