这里面的示例用gradle,初学者可以参考以下adle配置,熟悉者略过。
以下adle文件是通过spring initializer (/, 强烈推荐大家使用,特别是新建一个工程时,减少了很多繁琐的创建class / config / test 结构的过程) 快速生成的一个模板工程,然后加进了spring-boot-starter-aop的依赖。
注意Spring AOP 是一个保证了Spring 与 AOP的良好集成的实现,并非AspectJ, 后者是一门独立的语言,实现更全面。虽然两者有很多类似的概念。
plugins {id 'org.springframework.boot' version '2.2.0.RELEASE'id 'io.spring.dependency-management' version '1.0.8.RELEASE'id 'java'
}group = 'ample'
version = '0.0.1-SNAPSHOT'repositories {mavenCentral()
}dependencies {compile 'org.springframework.boot:spring-boot-starter-aop'implementation 'org.springframework.boot:spring-boot-starter-web'//classpath "gradle.plugin.aspectj:gradle-aspectj:0.1.6"testImplementation('org.springframework.boot:spring-boot-starter-test') {exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'}
}test {useJUnitPlatform()
}
ample.demo;public class Horseman {public int strength;Horseman () {strength = 5;}public void rush(String enemy) {System.out.Class().getSimpleName() + "rush" + enemy);}public int exercise(int experience) {strength += experience; return
本文发布于:2024-02-01 21:30:38,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170679424039538.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |