The MAVEN project, which runs normally on idea, but then runs after it has been made into a jar package, will have an exception: Exception in thread "main" Org.springframework.beans.factory.parsing.BeanDefinitionParsingException:Configuration problem:unable to locate Spring Namespacehandler for XML schema namespace [http://www.springframework.org/schema/context]offending resource: URL [Jar:file:/home/jiashubing/mysoft/jartest3/cli3.jar!/meta-inf/spring/spring-shell-plugin.xml] This error is not uncommon, But the online search is more for the project in the run time to report this error. There are also messages in the jar package that report this error, but all say that the version of the configuration file is inconsistent. I've tried all this and I can't solve it. After trying a lot of times, I finally found out that although I have spring-shell-plugin.xml this profile in my project,
This configuration file is not included in the jar package after it has been hit into a jar package。 Originally, in Idea, the MAVEN project would automatically scan the resource profile under the Src/main/resources path, so no additional configuration is required. The reason for automatic scanning is: Resource under the file compiled after the location, directly under the classes, this path is actually classpath path, so, in the resources root directory of the configuration file is actually classpath path but
after hitting a jar package, it is not automatically scanned for configuration files under the src/main/resources path, so it should be configured manually here so that it can scan to an XML configuration file. Just add the following code to the Pom.xml:<resources><resource><directory>src/main/resources</directory><includes><include>**/*.xml</include></includes></resource></resources>Original articles, reproduced please specify the source! Add the standard directory structure for MAVEN projects: Src-main–bin Script Library –Java Java source code files–resources Repository, which will be automatically copied into the classes directory.–filters Resource Filter File –assembly Component description Configuration (how to package) –config configuration file –webapp The directory of the Web App. Web-inf, CSS, JS and other-test–Java Unit Test Java source code files–resource libraries needed for the resources test–filters Test Resource Filter Library-site site (some documents) TargetLICENSE.txt project's LicenseREADME.txt project's Readme four directories of red fonts are commonly used
Run an error after hitting the jar package unable to locate Spring Namespacehandler for XML schema namespace