I am using spring 5.3.7
and when I start my application, it returns the error below:
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:
Constructor threw exception; nested exception is java.lang.NoSuchFieldError:
com/fasterxml/jackson/annotation/JsonInclude$Include.USE_DEFAULTS
I am using jackson-annotations-2.10.3.jar
which implements the USE_DEFAULTS Enum.
I hope some one can help me.
CodePudding user response:
You've code that is referencing a field that no longer exists in the class files.
The solution is to clean out all the class files and compile everything from fresh.
If you still get the same error after recompiling everything, then you're probably compiling against one version of an external library and using another at runtime.
What you need to do now is first identify the class that is causing the problem and then run your application with the (-verbose:class) command line option. It will dump a lot of class loading information on your standard out and you'll be able to find out where the problematic class is exactly loaded from.
CodePudding user response:
You should share your source code of dependency injection. However go through this one. Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:.
CodePudding user response:
I am not sure, but you should once check for the annotations like @Service, @Controller, @Respository, there are chances that you have missed any one of the annotations. just check it carefully, it might help you out.
CodePudding user response:
To deal with this error, we have to clear all .class files and recompile to ensure that all files are up to date.
If this error still exists at runtime, it may be that the dependency referenced at compile time is different from the runtime version. Here, it is necessary to check whether the various paths and versions are wrong.
Maven projects generally execute mvn clean.
Hope your problem can be solved