spring boot : The import org.springframework.jdbc.core.JdbcTemplate cannot be resolved

14,373

Solution 1

  1. delete the folder ‘spring-jdbc’ from the maven repository:

%your_path%.m2\repository\org\springframework\spring-jdbc

  1. open Eclipse -> right click on your project -> Maven -> Update project...

P.S. pom.xml should contain the jdbc dependency:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

Solution 2

Looks your IDE is not updating the dependencies, try run as maven project - install.

I suggest you to use springboot, also.

Share:
14,373
user641887
Author by

user641887

Updated on June 04, 2022

Comments

  • user641887
    user641887 almost 2 years

    I am having a hard time with one of my test programs which I am trying to write using springboot. When I try to import the JdbcTemplate class in the DAO layer I get an error : The import org.springframework.jdbc.core.JdbcTemplate cannot be resolved

    I am not sure what I am missing, I have checked the dependency and they look fine to me. Below is my pom.xml

        <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.vittles</groupId>
        <artifactId>FoodFood</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <name>FoodFood</name>
        <url>http://maven.apache.org</url>
    
     <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.2.RELEASE</version>
        </parent>
    
        <properties>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>
        </dependencies>
    
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    
    
    </project>
    

    Attached is the error which I get in my java file enter image description here

    Also attach is the list of jar imports . Can some one please let me know what I am doing wrong.

    enter image description here