spring-aop

@EnableAspectJAutoProxy not work with proxyTargetClass=false

北城以北 提交于 2020-01-02 05:38:12
问题 I am learning about Spring AOP at first time. I am reading about in this sites: Site2 and Site1 Following this I have made the next classes Main class: public class App { public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(AppConfig.class); context.refresh(); MessagePrinter printer = context.getBean(MessagePrinter.class); System.out.println(printer.getMessage()); } } App config class: @Configuration

Missing Spring AOP libraries in STS

蹲街弑〆低调 提交于 2020-01-01 12:34:09
问题 I'm getting my feet wet with Spring. I downloaded STS and I'm following basic examples from Spring in Action Second Edition. I'm stuck when trying to implement basic AOP and I guess I'm just missing some specific libraries in my project. I say so because annotations like @Aspect are not recognized in my classes like also <aop:config> in my xml. This are my Maven Dependencies: junit-4.7.jar spring-test-3.0.2.RELEASE.jar spring-context-3.0.2.RELEASE.jar spring-aop-3.0.2.RELEASE.jar aopalliance

Java AOP JoinPoint does not get parameter names

梦想的初衷 提交于 2020-01-01 06:18:44
问题 I'm using Java Spring Mvc and Spring AOP to find the parameter names from the user. I have a controller which get parameters from user and call a service. I have an aspect that running before the service. The aspect should check if username and apiKey parameters are exist. Here is my code : Controller : @RequestMapping(method = RequestMethod.POST, produces=MediaType.APPLICATION_JSON_VALUE) public @ResponseBody String getDomainWithFoundIn(@RequestParam (value="domain") String domain,

Spring AOP - pointcut for every method with an annotation

三世轮回 提交于 2019-12-31 08:29:15
问题 I am trying to define a pointcut, that would catch every method that is annotated with (i.e.) @CatchThis . This is my own annotation. Moreover, I'd like to have access to the first argument of the method, which will be of Long type. There may be other arguments too, but I don't care about them. EDIT This is what I have right now. What I don't know is how to pass the first parameter of the method annotated with @CatchThis . @Aspect public class MyAspect { @Pointcut(value = "execution(public *

How to make Lombok + Gson work with Spring AOP proxies

浪尽此生 提交于 2019-12-31 04:03:47
问题 Assuming there is a simple class Student @Data @NoArgsConstructor @AllArgsConstructor public class Student { private Integer age; private String name; } Add a logging aspect With Spring AOP in aop.xml <aop:config> <aop:aspect id="log" ref="logging"> <aop:pointcut id="selectAll" expression="execution(* com.tutorial.Student.getName(..))"/> <aop:before pointcut-ref="selectAll" method="beforeAdvice"/> <aop:after pointcut-ref="selectAll" method="afterAdvice"/> </aop:aspect> </aop:config> <bean id=

AspectJ: custom *.aj file is ignored

我们两清 提交于 2019-12-31 03:29:04
问题 Why aspectj-maven-plugin ignore my AnnotationInheritor.aj file? Am I configured something wrong? I want to advice ItemRepository#getById with custom annotation: @Repository public interface ItemRepository extends JpaRepository<Item, Long> { // AOP does not work, since autogenerated ItemRepositoryImpl#getById // won't have @MyAnnotation annotation @MyAnnotation public Item getById(Long id); } @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable

ぃ、小莉子 提交于 2019-12-30 18:07:46
问题 I am using Spring 4.2.4.RELEASE in my web application and I would like to remove the dependency on aspectjweaver.jar from it. I don't use AOP directly and I certainly don't use AspectJ. But my application fails with the following exception: java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable

≡放荡痞女 提交于 2019-12-30 18:07:17
问题 I am using Spring 4.2.4.RELEASE in my web application and I would like to remove the dependency on aspectjweaver.jar from it. I don't use AOP directly and I certainly don't use AspectJ. But my application fails with the following exception: java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable

你离开我真会死。 提交于 2019-12-30 18:07:06
问题 I am using Spring 4.2.4.RELEASE in my web application and I would like to remove the dependency on aspectjweaver.jar from it. I don't use AOP directly and I certainly don't use AspectJ. But my application fails with the following exception: java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357

Spring AOP: exclude avoid final classes and enums from pointcut

左心房为你撑大大i 提交于 2019-12-30 05:00:05
问题 I am using try to implement Logging using Spring AOP. I have defined the @Pointcut("execution(* com.mycom..*(..))") private void framework() {} @Around("framework()") public Object aroundAdviceFramework(ProceedingJoinPoint jp) throws Throwable { if (logger.isDebugEnabled()) logger.debug("DEBUG:: {} {} Enter", jp.getTarget().getClass().getName(), jp.getSignature().getName()); Object returnVal = jp.proceed(jp.getArgs()); if (logger.isDebugEnabled()) logger.debug("DEBUG:: {} {} Out", jp