`
Josh_Persistence
  • 浏览: 1651283 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类

Maven -Unable to locate Spring NamespaceHandler for XML schema namespace

阅读更多

            使用如下命令构建可执行Jar包时,如果使用的是新版本的Maven,在执行Jar包时会告知如下类似的错误:

Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [c11searcher-common.xml]

 

           

<plugin>  
                <artifactId>maven-assembly-plugin</artifactId>  
                <configuration>  
                    <appendAssemblyId>false</appendAssemblyId>  
                    <descriptorRefs>  
                        <descriptorRef>jar-with-dependencies</descriptorRef>  
                    </descriptorRefs>  
                    <archive>  
                        <manifest>  
                            <mainClass>com.ebay.montage.eventprocessor.collector.CodeRollOutEventDataCollector</mainClass>  
                        </manifest>  
                    </archive>  
                </configuration>  
                <executions>  
                    <execution>  
                        <id>make-assembly</id>  
                        <phase>package</phase>  
                        <goals>  
                            <goal>assembly</goal>  
                        </goals>  
                    </execution>  
                </executions>  
            </plugin>  

 

这是因为在新版本的Maven中,推荐使用shade来代替assembly 

于是可以使用如下plugin命令:

<plugin>  
     <groupId>org.apache.maven.plugins</groupId>  
     <artifactId>maven-shade-plugin</artifactId>  
     <version>2.1</version>  
     <executions>  
    <execution>  
         <phase>package</phase>  
        <goals>  
        <goal>shade</goal>  
        </goals>  
          <configuration>  
        <transformers>  
          <transformer  
    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
        <resource>META-INF/spring.handlers</resource>  
        </transformer>  
        <transformer  
    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
        <resource>META-INF/spring.schemas</resource>  
    </transformer>  
        <transformer  
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">  
    <mainClass>com.chuanliu.c11.bootstrap.C11SearcherBootStrap</mainClass>  
    </transformer>  
    </transformers>  
  
    <filters>  
      <filter>  
        <artifact>*:*</artifact>  
            <excludes>  
        <exclude>META-INF/*.SF</exclude>  
        <exclude>META-INF/*.DSA</exclude>  
        <exclude>META-INF/*.RSA</exclude>  
        </excludes>  
    </filter>  
    </filters>  
    </configuration>  
    </execution>  
       </executions>  
</plugin>  

 

这样同样使用mvn clean install -DskipTests后的jar包将被成功执行。

 

 

 

1
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics