Create Pointcut using simple name matching

You can create the Pointcut by simply matching the name of the method. We can use the NameMatchMethodPointcut class for this. In this example when you match “drive” for drive() and drive(speed). Spring does not care about the argument

We will start withe the class Car

Then you have the CarAdvice class with before method

You can test the code with following code. You can create the NameMatchMethodPointcut and use addMethodName() to add the name of the method you want to match

You can use this pom.xml file to get dependencies for this project

Now you can get the following output when you run the application