Dependency jar file classes are not importing in Gradle Groovy project

I am new to the Gradle and Groovy worlds. I have created a sample gradle-groovy project where I have added a dependency, and I want to make calls to those dependency classes and methods from my groovy file. But unfortunately, I am not able to build the project due to imported classes not being identified by my Groovy file, and I am getting an error message.

unable to resolve class com.fasterxml.jackson.databind.ObjectMapper
 @ line 3, column 1.
   import com.fasterxml.jackson.databind.ObjectMapper

Below added my project structure and build.gradle file
image

I am trying to import com.fasterxml.jackson.core:jackson-databind:2.15.1 jar from maven central repository and trying to create an object of ObjectMapper class.

For checking whether I am doing it correctly or not, I have created a gradle-java project, and from it I have added the same com.fasterxml.jackson.core:jackson-databind:2.15.1 dependency, and as expected, I was able to create an object of the ObjectMapper class provided by com.fasterxml.jackson.core:jackson-databind:2.15.1 and build the project. What am I doing wrong here?

buildSrc is a complete own build that is just automatically built before your main build and added to its build script classpath.
You need to there add an appropriate build.gradle(.kts) (and optimally also settings.gradle(.kts) as any build should have a settings script).
In that build script you need to add your dependencies you want to use in your classes in that project.
You added the library to the dependencies of your main project instead, so the buildSrc classes cannot find them.