Maven
aop.xml
当我们使用文件时无法打包spring-agent.jar
文件。
我们Surefire
用于运行单元测试用例和jacoco
获取代码覆盖率。
我们没有看到任何问题,spring-agent
但aspects
在运行时没有被调用。我们已经放置了aop.xml
下面的META-INF
文件夹,但它没有被拾取。
关于如何让 Maven 拾取aop.xml
文件并将其打包到META-INF
文件夹中的任何想法或指示?
这是我的 pom.xml 文件
*编辑**
这是我的 pom.xml .. 我删除了一些东西
<groupId>project-Web</groupId>
<artifactId>project-Web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>project-Web</name>
<properties>
<hibernate.version>4.2.3.Final</hibernate.version>
<spring.version>3.2.3.RELEASE</spring.version>
<spring.security.version>3.2.1.RELEASE</spring.security.version>
<jersey.version>1.8</jersey.version>
<project.dir>${basedir}</project.dir>
<project.libdir>${project.dir}/lib</project.libdir>
<skipTests>false</skipTests>
</properties>
<repositories>
<repository>
<id>maven-repo</id>
<url>http://maven.apache.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-oro</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-codec-1.3</groupId>
<artifactId>commons-codec-1.3.jar</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.libdir}/commons-codec-1.3.jar</systemPath>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>2.0.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mail</artifactId>
<version>2.0.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.7</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.4</version>
<scope>system</scope>
<systemPath>${project.libdir}/aspectjweaver-1.8.4.jar</systemPath>
</dependency>
<dependency>
<groupId>org.springagent</groupId>
<artifactId>spring-agent</artifactId>
<version>2.5.6</version>
<scope>system</scope>
<systemPath>${project.libdir}/spring-agent-2.5.6.jar</systemPath>
</dependency>
</dependencies>
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>local</env>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
</profile>
<profile>
<id>stage</id>
<properties>
<env>stage</env>
</properties>
</profile>
<profile>
<id>lt</id>
<properties>
<env>lt</env>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>generate-resources</id>
<phase>process-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${project.build.directory}/classes/config</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources/config/${env}</directory>
<includes>
<include>**/*.properties</include>
</includes>
<excludes>
<exclude>${project.basedir}/src/main/resources/config/${env}</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>${project.artifactId}-${project.version}</warName>
<webResources>
<resource>
<directory>${project.libdir}</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9</version>
<configuration>
<skinnyWars>true</skinnyWars>
<modules>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>project-Web</artifactId>
<contextRoot>/dev</contextRoot>
</webModule>
</modules>
</configuration>
<dependencies>
<dependency>
<groupId>comprojectservices</groupId>
<artifactId>project-Web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
<scope>system</scope>
<systemPath>${project.basedir}/target/project-Web-0.0.1-SNAPSHOT.war</systemPath>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4</version>
<configuration>
<forkMode>once</forkMode>
<argLine>
-javaagent:${settings.localRepository}/org/springframework/spring-agent/2.5.6/spring-agent-2.5.6.jar -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/1.8.4/aspectjweaver-1.8.4.jar
</argLine>
<useSystemClassloader>true</useSystemClassloader>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>test/resources</directory>
<includes>
<include>aop.xml</include>
</includes>
<targetPath>META-INF</targetPath>
</resource>
</resources>
</build>
</project>
still aop.xml is not getting picked up, becase aspects are not getting weaved.
i tried all approaches but not getting any clue where i am going wrong.
**BTW :** both the javaagents are in one line only.
does maven-resource-plugin is causing any issue here?