<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>蒋才的</title>
 <link href="http://caijiang.cc/atom.xml" rel="self"/>
 <link href="http://caijiang.cc"/>
 <updated>2026-04-11T06:08:44+00:00</updated>
 <id>http://caijiang.cc</id>
 <author>
   <name>蒋才</name>
   <email></email>
 </author>

 
 <entry>
   <title>Java如何在运行时获知自身Jar的版本</title>
   <link href="http://caijiang.cc/java/2016/05/09/java-jar-version-aware/"/>
   <updated>2016-05-09T10:30:52+00:00</updated>
   <id>http://caijiang.cc/java/2016/05/09/java-jar-version-aware</id>
   <content type="html">&lt;p&gt;按照Java Specification应当可以通过&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;getClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getPackage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getImplementationVersion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;或者&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;getClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getPackage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getSpecificationVersion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;实际上，这个值是依赖Java Jar规范的manifest信息。&lt;/p&gt;

&lt;p&gt;这个&lt;a href=&quot;http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Manifest_Specification&quot;&gt;链接&lt;/a&gt;是这个信息的详细规范。&lt;/p&gt;

&lt;p&gt;显然每次打包的时候手工写入这个文件是件坑爹的事情，我们需要将这个业务工程化，而且Maven已经做到了这点。&lt;/p&gt;

&lt;p&gt;非常简单的添加：&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-maven&quot; data-lang=&quot;maven&quot;&gt;    &amp;lt;plugin&amp;gt;
        &amp;lt;artifactId&amp;gt;maven-jar-plugin&amp;lt;/artifactId&amp;gt;
        &amp;lt;configuration&amp;gt;
            &amp;lt;archive&amp;gt;
                &amp;lt;manifest&amp;gt;
                    &amp;lt;addDefaultImplementationEntries&amp;gt;true&amp;lt;/addDefaultImplementationEntries&amp;gt;
                    &amp;lt;addDefaultSpecificationEntries&amp;gt;true&amp;lt;/addDefaultSpecificationEntries&amp;gt;
                &amp;lt;/manifest&amp;gt;
            &amp;lt;/archive&amp;gt;
        &amp;lt;/configuration&amp;gt;
    &amp;lt;/plugin&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;到我们pom.xml的build模块即可。&lt;/p&gt;

&lt;p&gt;package it &amp;amp; enjoy it!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Maven OutOfMemoryError</title>
   <link href="http://caijiang.cc/maven/2016/04/11/maven-out-of-memory-error/"/>
   <updated>2016-04-11T16:47:34+00:00</updated>
   <id>http://caijiang.cc/maven/2016/04/11/maven-out-of-memory-error</id>
   <content type="html">&lt;p&gt;在跑Maven Goal时可能会遭遇一些内存不足的问题。&lt;/p&gt;

&lt;p&gt;可以尝试更变环境变量给予运行Maven的JVM更多内存空间以修复该问题。&lt;/p&gt;

&lt;p&gt;在windows中可以尝试使用&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;MAVEN_OPTS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Xmx512m&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-XX&lt;/span&gt;:MaxPermSize&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;128m&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;或者在类Unix系统中用&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;MAVEN_OPTS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-Xmx512m -XX:MaxPermSize=128m&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;再重新跑Goal.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>管理Mysql常用指令</title>
   <link href="http://caijiang.cc/mysql/2016/04/08/mysql-common-manage/"/>
   <updated>2016-04-08T16:57:30+00:00</updated>
   <id>http://caijiang.cc/mysql/2016/04/08/mysql-common-manage</id>
   <content type="html">&lt;p&gt;&lt;img src=&quot;https://labs.mysql.com/common/logos/mysql-logo.svg?v2&quot; alt=&quot;Mysql&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;知识会更新，数据库系统也一样，本文只保证对Mysql 5.7以及MariaDB 10有效。&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;编码篇&quot;&gt;编码篇&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;展示当前默认的编码和字符集&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-mysql&quot; data-lang=&quot;mysql&quot;&gt;SHOW VARIABLES LIKE  &apos;char%&apos;;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;修改服务器默认编码,通过修改配置文件*.cnf&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-cnf&quot; data-lang=&quot;cnf&quot;&gt;skip-character-set-client-handshake
collation-server=utf8_unicode_ci  #特定字符集，如果没有特殊要求可以注释
character-set-server=utf8&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;统一表名大小写&quot;&gt;统一表名大小写&lt;/h3&gt;
&lt;p&gt;修改配置文件*.cnf，加入&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-cnf&quot; data-lang=&quot;cnf&quot;&gt;lower_case_table_names=1&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;这将强制保存的表名具体文件为小写，但在逻辑层面表名不再大小写敏感；
为什么这么干？因为阿里云RDS这么干？好处还是蛮多的，想了解更细节的规则或者有定制化的需求还是应该参考&lt;a href=&quot;https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html&quot;&gt;官方手册&lt;/a&gt;。&lt;/p&gt;

&lt;h3 id=&quot;用户和授权篇&quot;&gt;用户和授权篇&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;获取当前用户&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-mysql&quot; data-lang=&quot;mysql&quot;&gt;select user();&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;获取用户列表&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-mysql&quot; data-lang=&quot;mysql&quot;&gt;SELECT CONCAT(QUOTE(user),&apos;@&apos;,QUOTE(host)) UserAccount FROM mysql.user;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;创建一个可远程登录的用户root,并且设定明文密码&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-mysql&quot; data-lang=&quot;mysql&quot;&gt;CREATE USER &apos;root&apos;@&apos;%&apos; IDENTIFIED BY &apos;rawPasswd&apos;;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;授予可远程登录的root所有权限&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-mysql&quot; data-lang=&quot;mysql&quot;&gt;GRANT ALL on * to &apos;root&apos;@&apos;%&apos; WITH GRANT OPTION;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;将dbname的所有权限赋予dbuser&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-mysql&quot; data-lang=&quot;mysql&quot;&gt;GRANT ALL on dbname.* to &apos;dbuser&apos;@&apos;%&apos;;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;修改密码&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-mysql&quot; data-lang=&quot;mysql&quot;&gt;SET PASSWORD FOR &apos;dbuser&apos;@&apos;%&apos; = PASSWORD(&apos;rawPasswd&apos;);&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;删除用户&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-mysql&quot; data-lang=&quot;mysql&quot;&gt;DROP USER &apos;dbuser&apos;@&apos;%&apos;;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;导出与导入&quot;&gt;导出与导入&lt;/h3&gt;
&lt;p&gt;mysql现有热备份，dump，数据表文件，文本SQL记录，增量备份，组群备份，文件系统快照等多种导出导入的方式；从易用和实用角度考虑只记录dump的导出和导入。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;以user的身份连接到host:port导出database数据库到dump.sql&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;mysqldump &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;host] &lt;span class=&quot;nt&quot;&gt;--port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=[&lt;/span&gt;port] &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;user] &lt;span class=&quot;nt&quot;&gt;--default-character-set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;utf8 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;database] &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; dump.sql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;以user的身份连接到host:port导入dump.sql到database(需已存在)&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;mysql &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;host] &lt;span class=&quot;nt&quot;&gt;--port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=[&lt;/span&gt;port] &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;user] &lt;span class=&quot;nt&quot;&gt;--default-character-set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;utf8 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;database] &amp;lt; dump.sql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;或者以user的身份登录到host:port,再导入dump.sql&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;mysql &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;host] &lt;span class=&quot;nt&quot;&gt;--port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=[&lt;/span&gt;port] &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;user] &lt;span class=&quot;nt&quot;&gt;--default-character-set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;utf8 
use &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;database]
&lt;span class=&quot;nb&quot;&gt;source &lt;/span&gt;dump.sql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</content>
 </entry>
 

</feed>
