maven-assembly-plugin打Jar 出现异常
2017-11-27 11:34
309 查看
presto@yz-hadoopslave1 app]$ java -cp dataplatform-moxie-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.niwodai.data.parse.MoxieStart
17/11/27 11:21:29 INFO support.ClassPathXmlApplicationContext: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@3d71d552: startup date [Mon Nov 27 11:21:29 CST 2017]; root of context hierarchy
17/11/27 11:21:29 INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [applicationContext.xml]
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: class path resource [applicationContext.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
这个问题出现,看了下,原来是jar 问题,打包插件使用的是。
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
google 下,需要改为maven-shade-plugin插件。
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<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.AppendingTransformer">
<resource>META-INF/spring.tooling</resource>
</transformer>
</transformers>
<span style="color:#ff0000;"><filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters></span>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
17/11/27 11:21:29 INFO support.ClassPathXmlApplicationContext: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@3d71d552: startup date [Mon Nov 27 11:21:29 CST 2017]; root of context hierarchy
17/11/27 11:21:29 INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [applicationContext.xml]
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: class path resource [applicationContext.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
这个问题出现,看了下,原来是jar 问题,打包插件使用的是。
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
google 下,需要改为maven-shade-plugin插件。
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<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.AppendingTransformer">
<resource>META-INF/spring.tooling</resource>
</transformer>
</transformers>
<span style="color:#ff0000;"><filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters></span>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
相关文章推荐
- maven-assembly-plugin把java工程打包成为一个可执行的jar包
- maven-assembly-plugin把java工程打包成为一个可执行的jar包
- 使用Maven Assembly plugin将依赖打包进jar
- 构建工具-Maven-使用maven-assembly-plugin将依赖打包进jar并指定JDK版本
- maven-assembly-plugin 打包可执行jar(fat jar)和配置文件与jar同时打包部署
- Maven Assembly Plugin - 如何将Maven工程打成一个可执行jar包
- 使用Maven Assembly plugin将依赖打包进jar
- idea打包jar的多种方式,用IDEA自带的打包形式,用IDEA自带的打包形式 用Maven插件maven-shade-plugin打包,用Maven插件maven-assembly-plugin打包
- 使用eclipse执行maven-release-plugin插件发布jar异常问题(.project)(Cannot prepare the release because you have local modifications )
- maven-assembly-plugin把java工程打包成为一个可执行的jar包
- maven-assembly-plugin把java工程打包成为一个可执行的jar包
- 使用Maven Assembly plugin将依赖打包进jar
- Create a fat Jar file – Maven Assembly Plugin
- struts整合spring插件出现如下异常:Unable to load jar:struts2-spring-plugin-2.3.15.3.jar!/struts-plugin.xml
- maven error: 用maven下载的spring jar包出现该异常 cannot be read or is not a valid ZIP file
- Maven程序打包成单个Jar Part 1 -- Maven assembly plugin
- 使用maven的maven-assembly-plugin将jar包依赖打包到一个jar文件
- Maven编译jar出现:无法确定 T 的类型参数的异常的原因和处理方案
- 使用maven的maven-assembly-plugin将jar包依赖打包到一个jar文件中
- Maven编译jar出现:无法确定 T 的类型参数的异常的原因和处理方案