Error after ecplise export: No bean named 'XXX' is defined

After the project was packaged and placed in the linux environment, it was found that the project would report an error. The error reporting problems I encountered here include the following two aspects:
1. There is an implementation class of ApplicationListener in the jar package, and it is always found that it cannot be automatically executed when starting the project. I directly write the implementation class in the project and it can be executed automatically. I suspect that spring cannot scan it. The same class can also be executed automatically after the same folder is built.

Finally, it is suspected that there is a problem with the exported jar package. After confirming that there is no problem with the source code, the problem is narrowed down to a few checks when exporting the jar.
insert image description here
Add directory entries Add directory entries (few people know what this option is for, but it is really useful!

There is such a tag <context:component-scan /> in spring, which can be used to automatically scan the package, but if you do not check Add directory entries in the jar package you created, then your jar package cannot spring jar package can be scanned)

Or directly tick Export refactorings for checked projects, this will tick Add directory entries by default.

2. The XML file was not included when the project was packaged, causing the project to display abnormally when connecting to the database. The
solution: When packaging the project module JAR package, check Export all output folders for checked projects. The following are the four packages Chinese interpretation of the four options.
Export generated class files and resources: Indicates that only the generated [.class files and other resource files] are exported.
Export all output folders for checked projects: Indicates that [all selected folders] in the export project are exported.
Export java source file and resouces: Indicates that the exported jar package will contain your source code *.java, if you do not want to leak the source code, then do not select this option.
Export refactorings for checked projects includes some refactoring information files.

Guess you like

Origin blog.csdn.net/Hx230/article/details/127363299