SJS
SJS

Reputation: 5667

Can't import org.springframework.jdbc.core with maven

I dont know why the follow imports are not getting found in my project: Code:

import org.springframework.jdbc.core.SqlInOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.StoredProcedure;

I have the folllowing in my pom.xml file

Code:

<dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-context</artifactId>
 <version>3.2.1.RELEASE</version>
</dependency>

But I have found that if I add the following it works but I dont see why I need to:

<dependency>
      <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${springframework-version}</version>
</dependency>

Upvotes: 8

Views: 28125

Answers (3)

INDRAJITH EKANAYAKE
INDRAJITH EKANAYAKE

Reputation: 4274

The same error occurs when you run your Java code using the CodeRunner extension in VSCode. This happens because it can only deal with Java files and does not depend on any other third-party dependencies (reference).

The simple solution would be disabling CodeRunner and installing something like Extension Pack for Java and then the code will compile without errors.

Upvotes: 0

Reimeus
Reimeus

Reputation: 159774

SqlInOutParameter, SqlParameter and StoredProcedure require the spring-jdbc artifact.

It does not appear in the dependent artifacts for spring-context. The artifact for spring-orm does contain this dependency however. See here

Upvotes: 1

Gerard Ribas
Gerard Ribas

Reputation: 727

If you want to work with Spring Jdbc packages you have to import the correct library:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>3.2.1.RELEASE</version>
</dependency>

Upvotes: 8

Related Questions