如何确保 Spring roo 生成的方面是由依赖项目编织的? [英] How can I make sure that aspects generated by Spring roo are woven by a dependent project?

查看:31
本文介绍了如何确保 Spring roo 生成的方面是由依赖项目编织的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Spring Roo 多模块项目.我注意到,在另一个项目中包含包含我的域模型的 jar/模块后,方面并没有被编织让我拥有没有任何可用 getter/setter 的域类.

I have a Spring Roo multi module project. I noticed that after including the jar/module containing my domain model in another project, the aspects had not been woven leaving me with domain classes without any usable getters/setters.

如何确保 Spring roo 生成的方面是由依赖项目编织的?

EDIT:为了能够从另一个项目中使用 Roo 的方面,需要在依赖项目中包含 aspectJ 插件.请注意,这种方式不需要编译时加载.

EDIT: In order to be able to use Roo's aspects from another project, one needs to include the aspectJ plugin in the dependent project. Note that compile time loading is not needed that way.

推荐答案

需要在pom中包含aspectj maven插件:

You need to include the aspectj maven plugin in the pom:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.4</version>
            <!-- NB: do not use 1.3 or 1.3.x due to MASPECTJ-90 and do not use 1.4
                due to declare parents issue -->
            <dependencies>
                <!-- NB: 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>${aspectj.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                    <!-- NB: force aspect compile before normal compile, required for 1.3+
                        see: MASPECTJ-13, MASPECTJ-92 -->
                    <phase>process-sources</phase>
                </execution>
            </executions>
            <configuration>
                <outxml>true</outxml>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>

这篇关于如何确保 Spring roo 生成的方面是由依赖项目编织的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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