I changed the spring boot version to 3.4.1 in my pom.xml file and the issue was resolved. Just having the AnnotationTemplateExpressionDefaults imported through Spring Security 6.4 did not resolve the issue until the spingboot version was changed