Run an error after hitting the jar package unable to locate Spring Namespacehandler for XML schema namespace

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.