Component Scan does not scan for class problems in jar

  • 2021-12-11 07:37:10
  • OfStack

Directory Component-Scan does not scan the classes in jar about context: component-scan etc

Component-Scan does not scan classes in jar

Today, I encountered a strange problem. The configured spring


<context:component-scan base-package="*.*"/>

When deployed to the server, it is found that the classes in the jar package are not scanned, but they are normal locally.

After repeated tests, it was found that the original configuration was *. * After jar was really not scanned, it was changed to com.aa.bb.*.

My local test is normal because the maven dependency is directly dependent on the project locally, which can be scanned, but it is not possible to generate jar packages when deployed to the server.

Problem record about context: component-scan and so on

When using spring, it is found that as long as it involves the use of scanning packages, it will report that the version of jdk is too low or the class file in the package cannot be loaded.

Solve

You use jdk 1.8, then spring 3.2, or even 2.4. That's the problem. The two versions are incompatible

Then improve the spring version. Problem solved!


Related articles: