Tag Archives: Unable to locate Spring NamespaceHandler for XML schema namespace

Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace

This problem is that when spring is used, the local IDE runs normally, but an error is reported when running on the cluster after packaging.

After searching for information, the source of the problem was determined. Since many spring packages were called in the dependencies, there would be file coverage.

specifically is

These three files. After checking, only the configuration of tx is left.

Solution

The first method is to use maven’s packaging plug-in, which retains the configuration information of each spring package:

  1. <plugin>  
  2.     <groupId>org.apache.maven.plugins</groupId>  
  3.     <artifactId>maven-shade-plugin</artifactId>  
  4.     <version> 1.7.1</version>  
  5.     <executions>  
  6.         <execution>  
  7.             <phase>package</phase>  
  8.             <goals>  
  9.                 <goal>shade</goal>  
  10.             </goals>  
  11.             <configuration>  
  12.                 <transformers>  
  13.                     <transformer  
  14.                         implementation=“org.apache.maven.plugins.shade.resource.AppendingTransformer”>  
  15.                         <resource>META-INF/spring.handlers</resource>  
  16.                     </transformer>  
  17.                     <transformer  
  18.                         implementation=“org.apache.maven.plugins.shade.resource.AppendingTransformer”>  
  19.                         <resource>META-INF/spring.schemas</resource>  
  20.                     </transformer>  
  21.                     <transformer  
  22.                         implementation=“org.apache.maven.plugins.shade.resource.ManifestResourceTransformer”>  
  23.                         <mainClass>com.chenzhou.test.Main</mainClass>  
  24.                     </transformer>  
  25.                 </transformers>  
  26.             </configuration>  
  27.         </execution>  
  28.     </executions>  
  29. </plugin>

But this method is limited to packaging with this maven plugin. In fact, as long as these three files can contain complete configuration information, it’s fine.

The second method is actually very simple. Find these three files and overwrite them with the three complete files I provided.

Usually, these three files are in the META-INF path under the jar package