c3p0 reports an error java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector

1. Origin of the problem

When I learned c3p0 for the first time today, the learning materials used were version 0.9.1.2 .
I am lazy and using version 0.9.2 . But when running, an error will be reported:
Insert image description here

I searched this error online, and many people said to install the mchange-commons-0.2.jar package.
However, I saw that the learning materials did not install this package separately, and no error was reported. I think it's a jar package version issue

2. Find out

① You can search for 2 c3p0s from mvnrepository:
Insert image description here
② The first c3p0 is from version 0.9.2
https://mvnrepository.com/artifact/com.mchange/c3p0

③ The second c3p0 is as of 0.9.1.2
https://mvnrepository.com/artifact/c3p0/c3p0/0.9.1.2

④ Both c3p0 are official, but the storage addresses are different.
And from version 0.9.2 onwards, it needs to be used with the mchange-commons-0.2.jar package:
Insert image description here

In order to be consistent with the learning materials, I changed to version 0.9.1.2 , so it does not need to reference other jar packages.

3. Say goodbye correctly

Deleting version 0.9.2 may prompt that the deletion failed, even if the reference code is blocked
Insert image description here
. In this case, restart the idea and it will be fine. After restarting, you will find that the version that needs to be deleted is gone:
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_44050791/article/details/130185751