-3

I am trying to create a Spring aspect around method, but it is not getting called.

In my GeoLocationUpdateService.java:

@Autowired
private GeocoderService geocoderService;
...
geocoderService.findGeoLocation(...)

In com.myCompany.app.service.util.GeocoderService.java:

@Service
@CacheConfig(cacheNames = {"geoLocation"})
public class GeocoderService {

    public GeoLocation findGeoLocation(GeoMap geoMap, String address, String postalCode, String countryCode) {...}
}

In my com.myCompany.app.service.util.GeocoderServiceAspect.java:

@Aspect
@Component
public class GeocoderServiceAspect {

    @Around("execution(* com.myCompany.app.service.util.GeocoderService.findGeoLocation(..))")
        public GeoLocation findGeoLocation(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {...}
}

And in my WebMvcConfig.java:

@Configuration
@EnableSpringDataWebSupport
@EnableAspectJAutoProxy(proxyTargetClass = true)
@ComponentScan(basePackages = {"com.myCompany.app.*.web", "com.myCompany.app.service.util.*"})
@EnableAsync
public class WebMvcConfig extends WebMvcConfigurationSupport {...}

I put a breakpoint in GeocoderServiceAspect.java, but it did not break. It went into GeocoderService.java's findGeoLocation method.

The GeocoderServiceAspect.java's findGeoLocation method is not called.

1
  • 4
    So what I'd suggest you do is create a smallest possible prototype project with a painfully simple point cut - and get that working first. Then you can bring it across to your more heavyweight project. This particular question needs more information. Maybe a fully runnable project (include your pom.xml for example). Commented Nov 26 at 6:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.