{"id":2573,"date":"2015-12-12T13:35:47","date_gmt":"2015-12-12T05:35:47","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2573"},"modified":"2015-12-12T13:35:47","modified_gmt":"2015-12-12T05:35:47","slug":"%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8bjar%e5%8c%85%e7%9a%84%e7%89%88%e6%9c%ac%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2573.html","title":{"rendered":"\u5982\u4f55\u67e5\u770bjar\u5305\u7684\u7248\u672c\u4fe1\u606f"},"content":{"rendered":"<p>=Start=<\/p>\n<h5>\u7f18\u7531\uff1a<\/h5>\n<p>\u9700\u8981\u77e5\u9053\u4e00\u79cd\u901a\u7528\u7684\u65b9\u6cd5\u4ee5\u83b7\u53d6jar\u5305\u7684\u7248\u672c\u4fe1\u606f\uff0c\u56e0\u6b64\u6709\u4e86\u6b64\u6587\u3002<\/p>\n<h5>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/h5>\n<h6>how to check spring version<\/h6>\n<ul>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/947586\/need-spring-version-only-have-spring-jar-file\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/947586\/need-spring-version-only-have-spring-jar-file<\/a><\/li>\n<\/ul>\n<h6>JAR \u6587\u4ef6 \u89c4\u8303<\/h6>\n<ul>\n<li><a href=\"http:\/\/docs.oracle.com\/javase\/6\/docs\/technotes\/guides\/jar\/jar.html\" target=\"_blank\">http:\/\/docs.oracle.com\/javase\/6\/docs\/technotes\/guides\/jar\/jar.html<\/a><\/li>\n<li><a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/technotes\/guides\/jar\/jar.html\" target=\"_blank\">http:\/\/docs.oracle.com\/javase\/7\/docs\/technotes\/guides\/jar\/jar.html<\/a><\/li>\n<li><a href=\"https:\/\/zh.wikipedia.org\/wiki\/Manifest%E8%B5%84%E6%BA%90%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6\" target=\"_blank\">https:\/\/zh.wikipedia.org\/wiki\/Manifest%E8%B5%84%E6%BA%90%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6<\/a><\/li>\n<\/ul>\n<h6>\u83b7\u53d6jar\u5305\u7248\u672c\u4fe1\u606f<\/h6>\n<ul>\n<li><a href=\"http:\/\/blog.csdn.net\/xiaxiaorui2003\/article\/details\/4582778\" target=\"_blank\">http:\/\/blog.csdn.net\/xiaxiaorui2003\/article\/details\/4582778<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/heng_ji\/article\/details\/7058396\" target=\"_blank\">http:\/\/blog.csdn.net\/heng_ji\/article\/details\/7058396<\/a><\/li>\n<li><a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/technotes\/guides\/jar\/jar.html#The_META-INF_directory\" target=\"_blank\">http:\/\/docs.oracle.com\/javase\/7\/docs\/technotes\/guides\/jar\/jar.html#The_META-INF_directory<\/a><\/li>\n<li><a href=\"http:\/\/joshuasabrina.iteye.com\/blog\/1821406\" target=\"_blank\">http:\/\/joshuasabrina.iteye.com\/blog\/1821406<\/a><\/li>\n<li><a href=\"http:\/\/www.cnblogs.com\/wych\/p\/4072913.html\" target=\"_blank\">http:\/\/www.cnblogs.com\/wych\/p\/4072913.html<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/isea533\/article\/details\/49151139\" target=\"_blank\">http:\/\/blog.csdn.net\/isea533\/article\/details\/49151139<\/a><\/li>\n<li><a href=\"http:\/\/ifeve.com\/maven-2\/\" target=\"_blank\">http:\/\/ifeve.com\/maven-2\/<\/a><\/li>\n<\/ul>\n<h5>\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<p><span style=\"color: #0000ff;\"><strong>JAR\u6587\u4ef6\u672c\u8d28\u4e0a\u662f\u4e00\u4e2azip\u6587\u4ef6\uff0c\u5305\u542b\u4e00\u4e2a\u53ef\u9009\u7684META-INF\u76ee\u5f55\u3002<\/strong><\/span>\u591a\u6570\u60c5\u51b5\u4e0b\uff0cJAR\u6587\u4ef6\u5e76\u4e0d\u662f\u7c7b\u6587\u4ef6\u548c\/\u6216\u8d44\u6e90\u6587\u4ef6\u7684\u7b80\u5355\u805a\u5408\u6863\u6848\u3002\u4ed6\u4eec\u7ecf\u5e38\u7528\u4f5c\u5e94\u7528\u7a0b\u5e8f\u548c\u6269\u5c55\u7684\u6784\u5efa\u57fa\u7840\u3002\u5982\u679c\u5b58\u5728\u7684\u8bdd\uff0cMETA-INF\u76ee\u5f55\u7528\u6765\u5b58\u50a8\u5305\u548c\u6269\u5c55\u7684\u914d\u7f6e\u6570\u636e\uff0c\u5305\u62ec\u5b89\u5168\u3001\u7248\u672c\u3001\u6269\u5c55\u548c\u670d\u52a1\u3002<\/p>\n<p>\u5c06jar\u5305\u89e3\u538b\u540e\u8bfb\u53d6\u6587\u4ef6\uff1a<br \/>\n.\/META-INF\/MANIFEST.MF<br \/>\n\u5373\u53ef\u627e\u5230\u5bf9\u5e94\u7684\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<pre class=\"lang:default decode:true  \">$ unzip -p catalina.jar \"META-INF\/MANIFEST.MF\"\n...\nManifest-Version: Defines the manifest file version. The value is a legitimate version number, as described in the above spec.\n...\nSignature-Version: Defines the signature version of the jar file. The value should be a valid version-number string.\n...\nImplementation-Version: The value is a string that defines the version of the extension implementation.\n...\nSpecification-Version: The value is a string that defines the version of the extension specification.\n...<\/pre>\n<p>==<\/p>\n<pre class=\"lang:default decode:true \">\/\/ \u4e0b\u9762\u8fd9\u4e2a\u662f\u83b7\u53d6Spring\u7248\u672c\u4fe1\u606f\u7684\u4ee3\u7801(http:\/\/stackoverflow.com\/a\/947679)\nimport org.springframework.core.SpringVersion;\npublic class VersionChecker\n{\n    public static void main(String [] args)\n    {\n        System.out.println(\"version: \" + SpringVersion.getVersion());\n    }\n}<\/pre>\n<p>==<\/p>\n<p>\u9488\u5bf9Maven\u7ba1\u7406\u7684Jar\u5305<br \/>\n<span style=\"color: #ff0000;\">\u5728 pom.properties \u4e2d\u5305\u542b\u4e86jar\u5305\u7684\u7248\u672c\u53f7\u4fe1\u606f<\/span>\u3002<\/p>\n<p>==<\/p>\n<p>\u9488\u5bf9ANT\u7ba1\u7406\u7684Jar\u5305<br \/>\n\u5728 build.xml \u91cc\u5efa\u7acb\u4e00\u4e2a\u5b58\u653e\u7248\u672c\u53f7\u7684\u5c5e\u6027\uff0c\u5e76<strong><span style=\"color: #ff0000;\">\u5728\u6253Jar\u5305\u65f6\uff0c\u5c06\u7248\u672c\u53f7\u538b\u5165MANIFEST\u6587\u4ef6<\/span><\/strong>\u3002\u7a0b\u5e8f\u5728\u6267\u884c\u7684\u65f6\u5019\uff0c\u8bfb\u53d6Jar\u5305\u7684MANIFEST\u6765\u83b7\u53d6\u7248\u672c\u53f7\u3002<\/p>\n<p>====<\/p>\n<pre class=\"lang:default decode:true\">#\u67e5\u770bjar\u5305\u4e2d\u90fd\u6709\u54ea\u4e9b\u6587\u4ef6\uff1a\n$ unzip -l catalina.jar\n$ jar -tvf catalina.jar\n\n#\u4ece catalina.jar \u4e2d\u89e3\u538b\u51fa\u6587\u4ef6 ServerInfo.properties (\u9700\u8981\u77e5\u9053\u6587\u4ef6\u7684\u8def\u5f84\u4fe1\u606f)\uff1a\n$ jar xf catalina.jar org\/apache\/catalina\/util\/ServerInfo.properties\n\n#\u5c06\u4fee\u6539\u540e\u7684\u6587\u4ef6\u91cd\u65b0\u6253\u5305\u81f3 catalina.jar \u4e2d\uff1a\n$ jar uf catalina.jar org\/apache\/catalina\/util\/ServerInfo.properties\n\n#\u793a\u4f8b 1: \u5c06\u4e24\u4e2a\u7c7b\u6587\u4ef6\u5f52\u6863\u5230\u4e00\u4e2a\u540d\u4e3a classes.jar \u7684\u5f52\u6863\u6587\u4ef6\u4e2d:\n$ jar cvf classes.jar Foo.class Bar.class\n\n#\u793a\u4f8b 2: \u4f7f\u7528\u73b0\u6709\u7684\u6e05\u5355\u6587\u4ef6 'mymanifest' \u5e76\u5c06 foo\/ \u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u5f52\u6863\u5230 'classes.jar' \u4e2d:\n$ jar cvfm classes.jar mymanifest -C foo\/ .<\/pre>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u9700\u8981\u77e5\u9053\u4e00\u79cd\u901a\u7528\u7684\u65b9\u6cd5\u4ee5\u83b7\u53d6jar\u5305\u7684\u7248\u672c\u4fe1\u606f\uff0c\u56e0\u6b64\u6709\u4e86\u6b64\u6587\u3002 \u641c\u7d22\u5173\u952e\u5b57\uff1a how  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,12],"tags":[429,430,576],"class_list":["post-2573","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-tools","tag-jar","tag-maven","tag-meta-inf"],"views":15926,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2573"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2573\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}