编写Spring AOP程序的Maven依赖关系? [英] maven dependencies for writing Spring AOP programs?

查看:1412
本文介绍了编写Spring AOP程序的Maven依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Spring 5学习Spring AOP编程.我正在阅读在线材料.

I am trying to learn Spring AOP programming using Spring 5. I am going through online materials.

我知道AOP是一个概念,类似于OOP;借助AOP,OOP变得更加强大.

I came to know that AOP is a concept, similar to OOP; and with AOP,OOPs becomes more powerful.

现在,我正在尝试使用Spring框架版本5对AOP进行一些动手编码.

Now, I am trying to do some hands-on coding for AOP with Spring framework, version 5.

我将使用maven作为构建工具.

I am going to use maven as the build tool.

我不清楚在pom.xml中必须使用哪些依赖项,例如,我们需要使用以下依赖项吗:spring-aopspring-aspectsaspectj etc.

I am not clear on what are the various dependencies that we have to use in pom.xml, for example do we need to use: spring-aop , spring-aspects, aspectjetc.

任何人都可以指导我在pom.xml中添加哪些各种maven依赖关系,以便能够使用Spring 5 AOP程序maven工具进行编写?

Can anyone guide me what are the various maven dependencies that we have to add in pom.xml to be able to write using maven tool, Spring 5 AOP programs?

预先感谢

推荐答案

非常简单,为了在Spring上使用AOP,您需要在应用程序的类路径(版本1.6.8或更高版本)中存在Aspectjweaver库.这种依赖来实现

Its very simple, in order to work spring With AOP, You need aspectjweaver Library existe on the classpath of your application (version 1.6.8 or later).use this dependency to achieve that

<dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.13</version>
</dependency>

正如他们在文档中提到的

As they mention in docs

要通过Java @Configuration启用@AspectJ支持,请添加 @EnableAspectJAutoProxy批注:

To enable @AspectJ support with Java @Configuration add the @EnableAspectJAutoProxy annotation:

您可以找到更多信息使AOP起作用的唯一spring依赖项是著名的spring-context:

The only spring dependency to make something work with AOP is the famous spring-context :

 <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.0.2.RELEASE</version>
</dependency>

如果您想要一个工作示例,请在 github 中检查我的项目,该项目包含基本的Maven基于spring的AOP示例

If you want a working example check my project in github which contains basic Maven AOP example based on spring

这篇关于编写Spring AOP程序的Maven依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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