使用如下命令构建可执行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包将被成功执行。
相关推荐
使用assembly插件打包jar后启动时,总是出现Unable to locate Spring NamespaceHandler for XML schema....错误,网上找了各种方法都没有用,在尝试了100+失败后,解决了这个问题,在打包的jar中,META-INF目录下,...
java运行依赖jar包
2) A directory called "apache-maven-3.x.y" will be created. 3) Add the bin directory to your PATH, eg: Unix-based operating systems (Linux, Solaris and Mac OS X) export PATH=/usr/local/apache-...
009 maven插件spring-boot-maven-plugin
mybatis-plus-generator-maven-plugin-v1.0.0依赖的pom.xml,用于mybatis-plus-generator-maven-plugin-1.0.0.jar本地仓库上传时依赖使用
java运行依赖jar包
java运行依赖jar包
maven-3.5.0版本的本地资源包,直接解压就可使用。 方式1 需要在系统环境变量中直接配置path中配置,路径是到bin目录。 方式2 新建配置(MAVEN_HOME),路径为是解压后的maven根目录,再在path中引用(%MAVEN_HOME%\...
apache-maven-3.8.6,里面的settings.xml文件已经配置阿里云镜像。
maven-javadoc-plugin 插件 解决中文乱码 和注解 时间问题, 包括eclipse.ini设置、pom.xml设置、maven build GBK设置、eclipse注释设置、eclipse注释模版(可导入)。
maven-resources-plugin-2.4.1.jar
maven-archetype-webapp-1.0.jar,下载,如果有需要的同志可以自己下载,。
apache-maven-3.6.3全部版本的下载文件: apache-maven-3.6.3-bin.tar.gz; apache-maven-3.6.3-bin.zip; apache-maven-3.6.3-src.tar.gz; apache-maven-3.6.3-src.zip;
apache-maven-3.6.0,其中setting.xml文件已修改,采用阿里云中央仓库,下载到本地路径“E:\maven\maven-repository”,修改时只要将上面的路径修改成自己的就行。
解决Unable to create project from archetype [org.apache.maven.archetypes:maven-archetype-quickstart:1.1] 1. 下载maven-archetype-quickstart-1.1.jar 文件地址: 2.cmd窗口执行mvn install:install-file -...
apache-maven-3.6.0安装包,解压即用!
localRepository节点默认是被注释掉的,需要把它移到注释之外,然后将localRepository节点的值改为我们在3.1中创建的目录D:\Program Files\Apache\maven-repository。 3. localRepository节点用于配置本地仓库,本地...
在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven http://maven.aliyun.com/nexus/content/repositories/central/ central junit junit Address/ ...
maven-tomcat-plugin让maven与tomcat配合得很好。它可以把应用部署到Tomcat服务器,也可以把tomcat作为内嵌服务器启动,就像jetty一样。 使用JPDA启动tomcat的远程调试功能。这样就能与eclipse配合起来,轻松地实现...
apache-maven-3.6.1-bin.tar.gz liunx中的maven。