我正在尝试让AspectJ编织在一个简单的Maven项目中工作,并且不确定它出错的地方:当我使用"mvn exec:java"运行代码时,我看不到预期的输出.
我确信代码工作正常,因为我在STS中尝试了相同的工作,它工作正常.我只想让AspectJ在Maven项目中工作.
任何有关如何调试此类问题的提示将不胜感激.
<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>com.aop</groupId>
<artifactId>aop1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>aop1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version> <!-- specify your version -->
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</execution>
</executions>
<configuration>
<outxml>true</outxml>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<mainClass>com.aop.aop1.App</mainClass>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Run Code Online (Sandbox Code Playgroud)
Aspect文件与代码位于同一文件夹中:
package com.aop.aop1;
public aspect aspect {
pointcut secureAccess()
: execution(* …Run Code Online (Sandbox Code Playgroud) 我有以下aspectJ切入点:
@Around(value="execution(* *(*,Map<String, Object>)) && @annotation(com.xxx.annotations.MyCustomAnnotation)")
Run Code Online (Sandbox Code Playgroud)
如您所见,此切入点仅匹配使用 com.xxx.annotations.MyCustomAnnotation 注释的方法,该方法有 2 个参数 - 第一个是任意的,第二个必须是类型Map<String, Object>。
如果找到使用 com.xxx.annotations.MyCustomAnnotation 注释但与签名不匹配的方法,是否可以配置 aspectj-maven-plugin 以强制编译错误* *(*,Map<String, Object>)?
或者换句话说,:
@com.xxx.annotations.MyCustomAnnotation
public void test(String s, Map<String, String> m) {
...
}
Run Code Online (Sandbox Code Playgroud)
-> 我希望这会产生编译时错误,因为Map<String, String>!=Map<String, Object>
当我使用maven-apsectj-plugin和maven-compiler-plugin compile阶段将执行两个插件compile目标。这会导致javac首先使用 进行编译,然后使用 进行完全重新编译ajc。
这个双重编译有必要吗?看来我可以关掉maven-compiler-plugin一切,一切正常。
我正在使用“默认”配置,如用法中所述maven-compiler-plugin:
<project>
...
<dependencies>
...
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.13</version>
</dependency>
...
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
<build>
...
</project>
Run Code Online (Sandbox Code Playgroud) 我想按顺序合并多个视频并使用mp4parser获取一个视频
,但无法开始使用它...我在文件 gradle 中添加了 -implementation 'org.mp4parser:isoparser:1.9.27'
按照示例,无法找到
电影()
然后我意识到我需要添加插件aspectj-rt.jar,但找不到它的最新信息
请帮我解决这个问题。我在网络中看到许多开发人员成功地使用这个库来处理视频文件。但没有任何地方有关于如何开始使用 mp4parser 的信息。