I have a spring boot application wherein there is an aspect which logs method names and arguements.
@Component
@Aspect
public class LoggingAspect {
@Autowired
private ParameterNameDiscoverer parameterNameDiscoverer;
private static final Logger logger = LoggerFactory.getLogger(LoggingAspect.class);
@Pointcut("within(@org.springframework.stereotype.Service *)")
public void beanAnnotatedWithServiceOrASpecializationOfIt() {}
...
...
}
But when I deploy the application it says
Could not autowire field: private org.springframework.core.ParameterNameDiscoverer
Following is a part of pom.xml file that is being used
<properties>
<java.version>1.8</java.version>
<start-class>SampleApplication</start-class>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.M5</version>
</parent>
I want to log the method arguement names and their values as an aspect. I am getting the method arguement values but not their names.
Assuming you are using java config, you need to make sure you have a class annotated somewhere in your code with an
@Configurationand something like this:Note: there may be a more appropriate implementation of
ParameterNameDiscovererfor your particular use case, you should check the spring documentation for details.