Maven打jar包正常,但执行java -jar xxx.jar时,抛异常。
Unable to locate Spring NamespaceHandler for XML schema namespace rabbit
具体什么原因导致的未能查出,此处仅给出解决办法:
srping-rabbit.jar中的MATE-INF中的spring.handlers,spring.schemas,spring.tools中的数据拷贝到打包好的MATE-INF中对应的文件中
另贴出eclipse用maven打包的方法
pom.xml中和打包相关的配置:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.cz.sintech.main.NettyMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
eclipse添加本地maven:
JDK配置中加入MavenHome:
-Dmaven.multiModuleProjectDirectory=M2_HOME
-Xms2048m
-Xmx4096m
-XX:PermSize=128M
-XX:MaxNewSize=512m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=48m
-Dio.netty.leakDetectionLevel=paranoid
如果有乱码,把Common里的Encoding改为GBK