如何在具有 AspectJ 支持的 Eclipse 中创建 Maven 项目? [英] How to create a Maven project in Eclipse with AspectJ support?

查看:30
本文介绍了如何在具有 AspectJ 支持的 Eclipse 中创建 Maven 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎必须在使用某些 Eclipse 特定配置的AspectJ 项目"或Maven 项目"之间做出选择,然后尝试为 AspectJ 正确配置 XML.

It seems that one has to choose between "AspectJ project" which uses some Eclipse-specific configuration or "Maven project" and then trying to get the XML configuration for AspectJ right.

是否有我遗漏的某些 Eclipse 功能,或者是否有一个预制"/教程项目可以用作开始?

Is there some Eclipse feature that I'm missing or is there a "pre-made"/tutorial project which I can use as a start?

PS:我使用的是 Eclipse 3.7 (Indigo).

PS: I'm using Eclipse 3.7 (Indigo).

推荐答案

这里是我用来学习 AspectJ 的 pom 文件.

Here is the pom file I used to learn AspectJ.

<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>com.kowsercse</groupId>
    <artifactId>hello-aop</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <java-version>1.6</java-version>
        <org.aspectj-version>1.6.9</org.aspectj-version>
    </properties>

    <dependencies>
        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>
        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install</id>
                        <phase>install</phase>
                        <goals>
                            <goal>sources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <!--
                    Have to use version 1.2 since version 1.3 does not appear to work
                    with ITDs
                -->
                <version>1.2</version>
                <dependencies>
                    <!--
                        You must use Maven 2.0.9 or above or these are ignored (see
                        MNG-2972)
                    -->
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>${org.aspectj-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>${org.aspectj-version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outxml>true</outxml>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这篇关于如何在具有 AspectJ 支持的 Eclipse 中创建 Maven 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆