Reputation: 1576
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
Also attach is the list of jar imports . Can some one please let me know what I am doing wrong.
Upvotes: 4
Views: 29385
Reputation: 1
Update to match the parent version:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<type>pom</type>
<version>3.3.4</version> <!-- Change to match parent -->
<scope>import</scope>
</dependency>
<!-- Other dependencies -->
</dependencies>
Upvotes: 0
Reputation: 1447
%your_path%.m2\repository\org\springframework\spring-jdbc
P.S. pom.xml should contain the jdbc dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
Upvotes: 7
Reputation: 86
Looks your IDE is not updating the dependencies, try run as maven project - install.
I suggest you to use springboot, also.
Upvotes: 2
Reputation: 145
I checked with your code but its fine, it have JdbcTemplate library class, seems like a simple error. try to update your project "right click project->maven->update project" or clean maven.
Upvotes: 0