intelj idea 构建可执行jar包

1.Project Structure->Artifacts->点击“+”并选择JAR->From modules with denpendencies

intelj idea 构建可执行jar包_第1张图片

2.选择main类

intelj idea 构建可执行jar包_第2张图片

3.配置项目第三方jar包依赖,并配置classpath ,点号表示当前路径 

intelj idea 构建可执行jar包_第3张图片

4、构建jar

intelj idea 构建可执行jar包_第4张图片

打包完成后用解压软件打开查看文件目录如下:

intelj idea 构建可执行jar包_第5张图片

intelj idea 构建可执行jar包_第6张图片

5.运行jar包相关异常解决

(1)Invalid signature file digest for Mainfest main attributes

intelj idea 构建可执行jar包_第7张图片

 删除META-INF中RSA、SF后缀的文件:

intelj idea 构建可执行jar包_第8张图片

(2)Unable to locate Spring NamespaceHandler for XML schama namespace [http://www.speingframework.org/schema/context]

intelj idea 构建可执行jar包_第9张图片

确保引入了spring-context的jar包依赖以及版本正确。如果以上都没有问题,可能由于打包完成后spring.schemas、spring.hanlders中的配置不全导致出现此异常(详细参考:https://chenzhou123520.iteye.com/blog/1971322):

intelj idea 构建可执行jar包_第10张图片

添加spring 的配置:

http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http\://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd
http\://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd
http\://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd
http\://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd
http\://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd
http\://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd
http\://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
http\://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
http\://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd
http\://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd

确保spring 配置文件中context的配置匹配得上:

intelj idea 构建可执行jar包_第11张图片 spring.handlers中加上:

http\://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler
http\://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler
http\://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler

 

你可能感兴趣的:(java)