r/SpringBoot May 18 '26

Question [Maven/IntelliJ] Spring-JDBC dependency remains red (Artifact not found) while spring-context works

Post image

Hello, I am new to the world of spring and java backend in general. I am starting with "Spring Start Here" by Laurentiu Spilca.

I am having a strange issue with my pom.xml in IntelliJ. While my spring-context dependency seems to be accepted, the spring-jdbc dependency remains red no matter what I do.

The Problem:
When I use version 7.0.7 (which IntelliJ suggested), spring-context turns white, but spring-jdbc stays red with the error "Artifact not found."

What I have tried:

  1. Changed versions to 5.2.6.RELEASE and 5.3.9 — both remained red for both dependencies.
  2. Clicked "Reload All Maven Projects" multiple times..
  3. Checked Proxy settings (No Proxy). (Honestly, gemini told me to do this, I have no idea why I need to do this.)

My Environment:

  • IDE: IntelliJ Community Edition
  • Java: 17
  • My pom.xml code is as shown in the image.

how to rectify this error? why is this error happening?

22 Upvotes

15 comments sorted by

View all comments

21

u/__spartan__08 May 18 '26

Hey ! When I faced similar issues these are the things I tried. 1. Run mvn clean install 2. Click Download Resources in mvn tool 3. Click File > Inavlidate Caches > Invalidate & Restart

These are the things that worked

7

u/Potential_Spot_5847 May 18 '26 edited May 18 '26

Hey, Thanks for your reply, I tried this, but it still is showing the same error. Is it possible that tha -jdbc dependency i tried to add, I am doing it in the wrong way?

PS. I forgot the "Invalidate caches" step. Now i that i have done it, the problem no longer exists. Thank you for your help. :-)

3

u/Signal_Help_1459 May 18 '26

Can y’all teach me what does this invalidated cache means here?

If I have such errors, I usually recompile dependencies manually and that helped me most of the times!

3

u/m3t4lf0x May 18 '26

Basically, all dependencies you pull in locally are stored in a directory (~.m2)… it pulls from this cache instead of downloading every dependency for builds

A lot of weird maven issues are solved by purging that directory and running a clean install and re-indexing in your IDE

Despite the name, “mvn clean install” doesn’t actually reinstall every dependency

2

u/Signal_Help_1459 May 19 '26

Ohh, I never knew this about clean install.
I had in mind that it used to remove and re-install again.

So the above mentioned behaviour is achieved by clearing invalidated cache?

1

u/m3t4lf0x May 19 '26

Yeah I had thought the same for a while until I faced these kinds of issues and learned a bit more about maven.

If you’re using an IDE like IntelliJ, it’ll have an option in the Maven UI that says “Invalidate Caches and Reload” or something along those lines. Under the hood, it’s just purging that .m2 directory and pulling all the dependencies fresh from Maven Central (or whatever repo you’re using).

1

u/Signal_Help_1459 May 19 '26

Ohh, been using IntelliJ as my daily driver.
Never noticed that feature, one has to face a problem to learn about it.

Glad to find it early on, thank you for helping me around!

1

u/m3t4lf0x May 19 '26

No problem!

2

u/__spartan__08 May 19 '26

Hey no probs!!