2014/05/26

linux passwd 認証トークンエラー

現在のLinuxでは、パスワードは暗号化されて専用のファイル(/etc/shadow)に保存される。このファイルが書き換えられて/etc/passwdファイルと整合性が取れなくなってしまうと、passwdコマンドでパスワードを変更しようとしてもエラーになってしまう。そのようなときは、pwconvコマンドで両者の整合性を取れば、passwdコマンドが使えるようになる。

# passwd sato ←satoのパスワードを変更
Changing password for user sato.
passwd: Authentication token manipulation error ←エラーが出る
# pwconv ←パスワードファイルの整合性を取る
# passwd sato ←satoのパスワードを変更
Changing password for user sato.
New password: ←パスワードの入力プロンプトが表示された

2014/05/23

window task schedule jar

★Q:
I have an executable jar file and am trying to create a scheduled task using windows 7 Task Scheduler.
It runs fine as a .jar file when I double click it. But when I tell task scheduler to run it, it comes up with nothing.

★A:
"C:\Program Files\Java\jre7\bin\javaw.exe"
 -jar C:\Users\admin\Desktop\TestTask.jar

==>直接jar指定など。。javaで実行などうまくいかなかった。。。

java javaw

the javaw command is identical to java,
except that javaw has no associated console window.
Use javaw when you do not want a command prompt window to be displayed.
The javaw launcher displays a window with error information if it fails.

==>console window??親がない、自由な子供と見なう。
親の任務は起動されること。起動終わったら親が去る。
子供もなくなる。
そのときは、javaw!親が要らない!

2014/05/19

Linux Command netrc

・This file contains configuration and autologin information for the File Transfer Protocol client ftp(
 The .netrc file contains login and initialization information used by the auto-login process. It resides in the user's home directory. The following tokens are recognized; they may be separated by spaces, tabs, or new-lines:

machine name
    Identify a remote machine name The auto-login process searches the .netrc file for a machine token that matches the remote machine specified on the ftp command line or as an open command argument. Once a match is made, the subsequent .netrc tokens are processed, stopping when the end of file is reached or another machine or a default token is encountered.
default
    This is the same as machine name except that default matches any name. There can be only one default token, and it must be after all machine tokens. This is normally used as:

        default login anonymous password user@site

    thereby giving the user automatic anonymous ftp login to machines not specified in .netrc This can be overridden by using the -n flag to disable auto-login.
login name
    Identify a user on the remote machine. If this token is present, the auto-login process will initiate a login using the specified name
password string
    Supply a password. If this token is present, the auto-login process will supply the specified string if the remote server requires a password as part of the login process. Note that if this token is present in the .netrc file for any user other than anonymous ftp will abort the auto-login process if the .netrc is readable by anyone besides the user.
account string
    Supply an additional account password. If this token is present, the auto-login process will supply the specified string if the remote server requires an additional account password, or the auto-login process will initiate an ACCT command if it does not.
macdef name
    Define a macro. This token functions like the ftp macdef command functions. A macro is defined with the specified name; its contents begin with the next .netrc line and continue until a null line (consecutive new-line characters) is encountered. If a macro named init is defined, it is automatically executed as the last step in the auto-login process.
   

openssl update

cd /usr/local/src/
# wget https://www.openssl.org/source/openssl-1.0.1g.tar.gz
# tar -xzf openssl-1.0.1g.tar.gz
# cd ./openssl-1.0.1g
# ./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib shared zlib-dynamic
# make
# make install
------------------------------------------------------------------------------


まだ1.0.1eのままですが、適応されたバージョンのchangelogを確認すると

Changes in packages about to be updated:

ChangeLog for: openssl-1.0.1e-16.el6_5.7.x86_64, openssl-devel-1.0.1e-16.el6_5.7.x86_64
* Mon Apr  7 21:00:00 2014 Tom?? Mr?z  1.0.1e-16.7
- fix CVE-2014-0160 - information disclosure in TLS heartbeat extension

とあるので、バージョンは変わってないけど、パッチは当たっている状態かと思われます。

# service httpd restart

最後にApacheの再起動を行なって反映されます。

mysql_secure_installation 個別

・mysql_secure_installation は UNIX ドメインソケットを設定できないため、個別の MySQL に対して mysql_secure_installation を実行することができません。
解決策としては、

ln -s /var/lib/mysql/mysql-db1.sock /var/lib/mysql.sock
/usr/bin/mysql_secure_installation
rm -f /var/lib/mysql/mysql.sock

リンクを貼って、個別にやる!

node.js install

■node.jsをインストール
・リポジトリ追加(64bit)
yum repolist all
rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
・yum install nodejs npm --enablerepo=epel
・Node向けパッケージ管理ツールnpm

■ Sailsをインストールする
npm install -g sails
sails new simpleChat --linker
sails lift


★★linux Another app is currently holding the yum lock; waiting for it to exit...
==>rm -f /var/run/yum.pid


サーバサイドJavaScriptには、「CommonJS」と呼ばれる標準化が策定されています。
・Node.jsは、このCommonJSに則って開発されています。

・Node.jsとは、サーバサイドJavaScriptの1つですが、「シングルスレッドベースの非同期処理環境」という特徴を持っています。

・Node.jsは、あくまでサーバー側のJSのContextであり、JSはここで実行できる!経験上常に使うことをモジュールにされ、libraryになった。


★non-blocking communication
==>
データの送受信を行う際に、送受信の完了を待たず、他の処理を開始する通信方法。並列処理の一種。

ノンブロッキング通信では、通信機器・プログラムが行う実際の通信処理と並列に、通信が完了していなくとも可能な処理を進め、通信が完了していないとできない処理にたどりついた場合には、そこで通信の完了を待つことになる。これに対し、正常に送信できたかどうか通信の結果を待ち、通信が完全に完了してから残りの処理を行う方式をブロッキング通信(ブロッキングモード)という。

通信相手との同期を取らない点では一種の非同期通信といえるが、いわゆる非同期通信が単に通信相手からの返事を待たない(同期を取らない)というニュアンスであるのに対し、ノンブロッキング通信では主に、通信処理の完了を待つことによって他の処理の進行を妨げないことを表わしている。

html dt dd dl


<dl>
<dt>ジョン・レノン</dt>
<dd>1940年10月9日リヴァプール生まれ。</dd>
<dt>ポール・マッカートニー</dt>
<dd>1942年6月18日リヴァプール生まれ。</dd>
</dl>

<dl compact="compact">
<dt>ジョン</dt>
<dd>1940年10月9日リヴァプール生まれ。</dd>
<dt>ポール</dt>
<dd>1942年6月18日リヴァプール生まれ。</dd>
</dl>

play framework template

・testProject/app/models/Products.java
・testProject/app/views/productList.scala.html
・testProject/app/controllers/Products.java
・マッピングファイル:
testProject/conf/routes
#products
GET /products/ controllers.Products.list()
===>MVCだね。。


・testProject/app/controllers/Products.java

import views.html.products.list;
★==>templateのViewをimporする.targetのところでコンバインしてくれた。。
testProject\target\scala-2.10\classes\views\html

public class Products extends Controller {
public static Result list() {

★==>モデルのメリットを呼び出す
Set<Product> products = Product.findAll();
return ok(list.render(products));
}
...
}

The render method on the template results in an HTML page, which we want
to return to the client in the body HTTP response. To do this, we wrap it in a
Result object, by passing it to the ok method


sessionless API.
‘refresh an entity’, or what the difference between and ‘attached’ entities and
‘detached’ entities.


・テンプレートは簡単な命名規則に従って、ただの Scala の関数としてコンパイルされます。views/Application/index.scala.html というテンプレートファイルを作成すると、コンパイルにより views.html.Application.index という関数が生成されます。

・Scala テンプレートでは @ という文字が唯一の特殊文字です。この文字はテンプレート中に登場すると Scala コードの開始として認識されます

・テンプレートはただの関数なので、引数をとります。引数はテンプレートの先頭行で宣言します。
@(customer: models.Customer, orders: Seq[models.Order])
@(title: String = "Home")
@(title:String)(body: Html)
@(title: String)(body: Html)(implicit request: RequestHeader)

play framework directory

★target directory
==>the target directory. There’s
only one thing you have to know about the target directory: you should ignore it.
The target directory is the build process’ working directory. This is where your
compiled classes are stored, among other things. Just be sure to never commit it in
your versioning system.

★The conf directory is where you configure the application.
application.conf=>This is where you’ll configure things like logging, database
connections, which port the server runs on, and more.
routes ? mappings from HTTP URLs to application code

★import into eclipse
cd theProject
play
console
!
!:-->履歴
play eclipse===>eclipse用のプロジェクトファイルを生成する

bash-completion

bash-completion は、次のコマンドの入力補完を行えるようにするためのソフトウェアです。次のコマンドが対象となっています。

hsperfdata

JDK1.4.2以降では、Javaプロセス動作時(Javaアプリケーション動作時)に、Java VMはシステムの一時作業領域(注)に「hsperfdata_ユーザ名」というフォルダ(またはディレクトリ)と、その配下に数字名の一時ファイルを作成します。これは、Java VM動作中に内部的に使用するファイルで、Java VMの動作中以外は不要となりますので、資産として、バックアップ対象とする必要はありません。

linux alternatives

・設定
    sudo alternatives --config java
   
・選択肢を追加する
    alternatives --install /usr/bin/java java /opt/jdk1.6.0_17/bin/java 3

Vagrant 試し

★vagrant box add chef/centos-6.5 (url)
==>This will download the box named "chef/centos-6.5" from Vagrant Cloud,
a place where you can find and host boxes.
 While it is easiest to download boxes from Vagrant Cloud you can also add boxes from a local file, custom URL, etc.


★vagrant proxy
WIndows7 のシステム環境変数 http_proxy に proxy_host:proxy_port のフォーマットで設定すればよいようです。
https_proxy   proxy_host:proxy_port

vagrant init
vagrant up

★仮想マシンに接続する
vagrant ssh
vagrant status
vagrant halt
vagrant destory {name}


★ターミナルで接続する方法
例えばTeraTermとかで接続したいとき。
vagrant initした際に作成されたVagrantfileのconfig.vm.networkを下記のように設定。
(コメントアウトされてるのでそれを有効にすればよい。)

config.vm.network :private_network, ip: "192.168.33.10"

これでターミナルから「192.168.33.10」でsshできる。
ユーザとパスワードは「vagrant」。rootになるにはノンパスで「sudo -s」。
これは「ホストオンリーネットワーク」といって、ホストOSからしかゲストOSへアクセスできない。
VirtualBoxでいうと「ホストオンリーアダプター」を設定していることになる。
※「:hostonly」って書き方もあるが、古いらしい。
他にも以下のようなネットーワーク設定が可能。

ansible parallelism pull


-f==>using a parallelism level of 10
ansible-playbook playbook.yml -f 10

★Ansible-Pull
==>checkout a repo of configuration instructions from git, and then run ansible-playbook against that content.
・it allows you to automatically deploy the latest code in your repository, even if the servers are different
・I find the fact that you don’t have to run a deploy step, other than just committing, completely magical.
==>これはいいの?

linux make install uninstall

★install
% wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p374.tar.gz

% tar xzf ruby-1.9.3-p374.tar.gz
=>適当な場所でアーカイブを展開する

% cd ruby-1.9.3-p374
% ./configure
=>configure スクリプトがある場合は[./configure --help]
=>/usr/local にインストールするなら --prefix=/usr/local、ホームディレクトリなら --prefix=$HOME という感じでオプションをつける。
==>Makefileが自動生成される。

% make
==>これはビルドである!

% sudo make install
==>これはインストール


★uninstall
configureの中にuninstallがあれば、
==>make uninstall でOK

-prefix や --enable-layout オプションを指定していないのであれば、デフォルトで /usr/local/apache または /usr/local/apache2 にインストールされるので、そのディレクトリごと削除してしまえばよいでしょう。
それ以外の他のファイルが存在するところにインストールしてしまった場合は、手で1つずつ探して削除するしかありません。

chef install

chef-soloでstandalone型の物を試す:

・yum install ruby ruby-devel rubygems make gcc
・sudo curl -L https://www.opscode.com/chef/install.sh | sudo bash

mkdir -p chef-repo/cookbooks
cd chef-repo/cookbooks
knife cookbook create setup-user -o .
-o .==>output を今のところにする

Jasper report Font not found exception

★reportでやる場合

If the fonts you used are not yet installed (they probably aren't), you'll need to install them.
Click the "Install Font" button. A wizard will pop up, asking you the font name and the location of the ttf files.
Just direct the application to the location of the ttf files (for windows systems this is generally in the windows\fonts folder).
Make sure to check the "Embed this font in PDF" checkbox on the second page! All other settings can be left at their defaults.
Once all the fonts are installed, you select all the fonts you used in your report (hold <code>ctrl</code> to select multiple entries from the list).
Then you click the "Export as extension" button. This will create a jar file.
All you need to do is add the created jar file to the classpath of your application and you're done!
===>うまくいかない。。。


==>そのfontのファイルをjreのfontにコピーする
.../jre/lib/fonts/
==>OK

127.0.0.1 localhost Ip

localhost
不联网
不使用网卡,不受防火墙和网卡限制
本机访问

127.0.0.1
不联网
网卡传输,受防火墙和网卡限制
本机访问

本机IP
联网
网卡传输 ,受防火墙和网卡限制
本机或外部访问

2014/05/16

2014/05/14

linux ansible install err No such file or directory

sudo yum install ansible==>

ansible を実行して、エラーになる。。

  File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory


=====>
Sorry for the confusion, I found this duplicate thread.
Indeed, openssh-clients was missing. Now it looks much better.
Thanks for pointing me to the right direction!
===>openssh-clients!!!

wget プロキシ経由

etc/wgetrc に以下の内容を追記する。

デフォルトではコメントアウトされて無効になっている。

/etc/wgetrc
http_proxy = http://1.1.1.1:port/
これで、wget を実行するとプロキシ経由になっている。
さらに https をプロキシ経由にする場合は次の通り。

https_proxy = http://1.1.1.1:port/
上の設定をして、逆にプロキシを経由したくない場合には、
wget コマンド実行時に次のように --no-proxy オプションを指定する。

# wget --no-proxy https://www.verisign.co.jp/index.html

ちなみに、https でファイルを取得する時に証明書のエラーで取得できない場合がある。
その場合は次の通りにすれば証明書のエラーを無視してファイルを取得できる。

# wget --no-check-certificate https://www.verisign.co.jp/index.html

linux nslookup dig インストール

DNSの設定を確認するnslookupやdigは、bind-utilsパッケージに含まれます。bind-utilsパッケージがインストールしましょう。

# bind-utilsパッケージのインストール
yum -y install bind-utils

 これで、nslookupコマンドとdigコマンドが使用できます。

# nslookup
nslookup ドメイン名

# dig
dig ドメイン名

2014/05/13

Python pip インストール エラー



※CentOS6.5

★Python Package Index(pip)とは
Python Package Index(以下、pip)とは、Pythonにおけるパッケージ管理システムで、rubyのgemやperlのcpanみたいなものです。
pipは同様のパッケージ管理システムである、『setuptools』の"easy_install"を置き換えます。
pipをインストールするには、まずはsetuptoolsをインストールする必要があります。

★yumインストールでエラーになった!
Searching for pip
Reading http://pypi.python.org/simple/pip/
Download error: [Errno -2] Name or service not known -- Some packages may not be found!

・setuptoolsを確認する
 yum info python-setuptools
 ==>パッケージの情報を確認する

・ setuptoolsを再インストールする
 sudo yum -y remove python-setuptools
そして、最新の setuptools を自分で取ってきてインストールする。 pip もそこから改めて入れる。 要するにクリーンインストールする。
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python
$ sudo easy_install pip
==>エラーになる。。。 easy_installで

 ★直接pipのインストール

①次のサイトあたりでダウンロードURLを確認して、ダウンロード。
※参照先らしいサイト
https://pypi.python.org/pypi/pip
wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz

②解凍します。
    tar xvzf pip-1.3.1.tar.gz

③解凍したディレクトリ内に移動してインストール。
    cd pip-1.3.1
    sudo python setup.py install --record files.txt

すると、次のような感じで、pipが使えました…

★uninstall

cat files.txt | xargs rm -rf

linux rpm

★RPMとは、
・RedHat Package Manager?
Linuxでパッケージ管理環境が貧弱だった1994年ごろにリリースされました
RPMのパッケージ管理システムとしての特徴は下記のようになっています
    パッケージのインストール・アンインストール・アップグレードが容易
    他のパッケージとの依存関係の調査が可能
    ソース・パッチ管理が可能
    ビルド手順の記録・再現が可能
    パッケージ情報の多彩なキーで検索が可能
    擬似パッケージ名の使用が可能.例えば「httpd(apache)はwebserverというパッケージ名も兼ねる」といったことが出来,
    ウェブサーバーの種類にとらわれないパッケージは,httpdに依存するのではなく,webserverに依存するといった構築が可能になる.

★ファイルの書式:
<NAME>-<VERSION>-<RELEASE>.<ARCHITECTURE>.rpm
==>ARCHITECTURE OS、BITなど。。。
MySQL-client-5.6.16-1.el6.x86_64.rpm

★SRPM
==>RPMを作成するために必要なアーカイブやパッチファイルやデータのファイルなどをまとめたファイルになります
通常SRPMがあると,rpmbuildコマンドで再度RPMファイルを作成することが出来ます.
rpm --rebuild php-4.3.7-1.src.rpm

★SPEC
==>RPMを作成するための作業手順やRPMの情報などを記述したファイル.このファイルを用いてRPMを作成する


★rpmbuild
・/usr/bin/yum install rpm-build
-bb    SPECファイルを用いてRPMファイルをビルドします.
例:redisのインストール

$ mv redis.spec rpm/SPECS/
$ mv redis-2.4.17.tar.gz rpm/SOURCES/
$ rpmbuild -bb rpm/SPECS/redis.spec

★変更履歴
rpm -q --changelog openssl | head -n 3

Linux 環境変数

ログイン時に読み込むスクリプトと環境変数はどこに設定すればいいのか。

シェルがbashの場合。

/etc/profile
ログインしてまず読み込む
ユーザ全体向けの環境変数を書く

/etc/profile.d/
/etc/profileのスクリプトにより/etc/profile.d/の下にあるスクリプトが実行される。

~/.bash_profile
個別ユーザ向けの環境変数はここに書く

~/.bashrc
~/.bash_profileのスクリプトによって実行される
エイリアスなどシェルの基本設定を書く

/etc/bashrc
~/.bashrc のスクリプトによって実行される
全ユーザ向けの設定を書く

CentOS ant インストール

★バイナリ形式のtar.gzファイルをダウンロードし
★環境変数を設定する
touch /etc/profile.d/ant.sh
=->export ANT_HOME=".."
  export PATH="$PATH:ANT_HOME/bin"
★拡張jarを全て ANT_HOME/libの下に入れる

yum方式やめる方がいい

2014/05/09

MySQL GTID replication 理解深め

★gtid_mode must be ON on all servers or OFF on all servers
★GSo once GTIDs are enabled on all servers, you can have some slaves using file-based positioning and some other slaves using GTID-based positioning.


★GTID関係するパラメータ
mysql> show variables like '%gtid%';
+--------------------------+-----------+
| Variable_name            | Value     |
+--------------------------+-----------+
| enforce_gtid_consistency | ON        |
| gtid_executed            |           |
| gtid_mode                | ON        |
| gtid_next                | AUTOMATIC |
| gtid_owned               |           |
| gtid_purged              |           |
+--------------------------+-----------+


★START SLAVE SQL_THREAD UNTIL SQL_BEFORE_GTIDS = 3E11FA47-71CA-11E1-9E33-C80AA9429562:11-56
START SLAVE SQL_THREAD UNTIL SQL_AFTER_GTIDS = 3E11FA47-71CA-11E1-9E33-C80AA9429562:11-56


★START SLAVE UNTIL SQL_AFTER_MTS_GAPS
==>his statement causes a multi-threaded slave's SQL threads to run until no more gaps are found in the relay log, and then to stop
START SLAVE UNTIL SQL_AFTER_MTS_GAPS should be used before switching the slave from multi-threaded mode to single-threaded mode (that is, when resetting slave_parallel_workers back to 0 from a positive, nonzero value) after slave has failed with errors in multi-threaded mode.

ーーーーーーーーーーー
START SLAVE UNTIL SQL_AFTER_MTS_GAPS;
SET @@GLOBAL.slave_parallel_workers = 0;
START SLAVE SQL_THREAD;
ーーーーーーーーーーー


★MySQL Utilities Launchpad page. ==>python?


★enable GTID replication for an easier rollback in the event of a problem?
どうやる???

★show global variables like 'gtid_executed';
+---------------+--------------------------------------------+
| Variable_name | Value                                      |
+---------------+--------------------------------------------+
| gtid_executed | d3acef65-d68e-11e3-b9f4-08002760d1b6:1-981 |




+---------------+--------------------------------------------+



★オペレーション
当一个slave接到master, 个新的协议将确保GTIDs的范slave经执行的和已提交但失的事. master然后送除此以外的其它事, 也就是那些slave没有行的.==>依慢的状况为准 !自动比较!
有了一个可靠的slave, 确保任何的事slave上都会被行并且不会因master的事件失而

The only part were we should pay attention is the server we choose for promotion: if it is not up-to-date, data may be lost or replication may be broken.

SLAVE出错了,不知道什么原因。。GRID模式下,大部分都是自动的,变量也是只读的。。。
由于运行在GTID模式,所以不支持sql_slave_skip_counter语法
set global gtid_executed=''; set global gtid_purged=''
ERROR 1238 (HY000): Variable 'gtid_executed' is a read only variable
SLAVE上!
Reset master
Stop slave
Reset slave
还记才的gtid_purged那个点,只需重新置下一个点即可
è????!!
set global gtid_purged='cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-141';

auto_position=0 ,很简单根据指定的 binlog 文件和偏移量, Master binlog 中的各个数据更事务发给备库就好了。备库接收到对应的事,判断是否本机起的 ( 数据更事务记录 server_id 来判断 ) ,如果不是本机起的,就直接行。
auto_position=1 备库将自己的 gtid_executed 的事集合传给 Master Master 找到第一个包含有非备库 gtid_executed 集中数据更的 binlog ,将 binlog 中的各个 event 给备库这样备库首先判断是否本机起的,然后判断来的各个数据更事是否在本机。没有的事都需要在本地行一遍。
Retrieved_Gtid_Set 记录的是 IO thread 从主拿到的事

★回想一下,我之前做的操作:手工除了 binlog 日志和 binlog index 文件,然后启 MySQL 个操作在没有启 GTID MySQL 上,我也做过类似的事情,备库并没有复制失的问题。我手工除了 binlog 以后,数据生成 binlog 。但是在 Master 中,它重新从 9300dd57-51da-11e3-989d-3cd92bee36a8:1 第一个事开始数。从另外一个面来,已经执行完的 GTID 集合, MySQL 并没有独保存,而是通 Binlog 得的。
备库经执行完了 9300dd57-51da-11e3-989d-3cd92bee36a8 :1 - 28123 些事。所以当 SQL thread 拿到从主复制来的更事务时发现这些事都是它已经执的事,那么它就不会再重复行,从而对应些事都会被失掉。如果在某种情况下,我需要在手工除,并启数据,建 auto.cnf 清理掉。这样会生成新的 UUID 备库发现是新的事就会更了
LOAD DATA FROM MASTER;
LOAD TABLE TBLNAME FROM MASTER;

linux java.net.UnknownHostException

新しいサーバーを作って、立ち上がり、いきなり。。
ーーー
InetAddress.getLocalHost()
=>java.net.UnknownHostException
ーーーー

/etc/hosts ファイルの内容は、ホスト名とIPアドレスとの対応表です。
IPアドレスからホスト名を知りたいとき、またはホスト名からIPアドレスを知りたいときに、このファイルが参照されます。
/etc/hostsファイルの書式は以下の通りです。
<アドレス> <ホスト名> [別名 ...]

==>新しいモン追加して、OK

2014/05/07

ant

★ant
ant -buildfile test.xml
ant -buildfile test.xml dist
ant -buildfile test.xml -Dbuild=build/classes dist
-->buildFileをtest.xmlを使う。タスクをdistにする。
 build属性を「build/classes」にする
 
★java言語を使って、新たな機能を追加できる。

★build.xml、eclipseで書く方が楽。

★platform間の溝を埋めるために作った。
=ー>実行できない。。

これだけ、後は使う時調べる。

maven 入門

mvn archetype:generate
->generate project in Interactive mode
・アーキタイプを指定する
=>
デフォルトが203(org.apache.maven.archetypes:maven-archetype-quickstart)になっているので、それを選んでみる
・versionを指定する
・groupIdを指定する
==>これは、何をやっている?
シンプルなクラスつくてくれた。。。。
ーー>test1を作る!

★Mavenでは「リポジトリー」という場所でアーカイブ(jarファイルやソースファイル等)を保管しておき、Mavenで管理された各アプリケーションではそれを参照する。
リポジトリーには「リモートリポジトリー」と「ローカルリポジトリー」がある。
リモートリポジトリーはインターネット上で公開されているリポジトリーで、ローカルリポジトリーは自分のマシン上に(自動的に)構築されたリポジトリー。
Mavenではpom.xmlにアプリケーションが依存(使用)するライブラリーを記述する。
Mavenのコマンドを実行すると、その依存関係に従ってリモートリポジトリーからライブラリー(アーカイブ)をダウンロードしてローカルリポジトリーに格納する。
そして、各アプリケーションはローカルリポジトリー内のファイルを参照して処理を行う。
(例えばローカルリポジトリー内のjarファイルをクラスパスに追加してアプリケーションをコンパイルしたり実行したりする)
==ー>リポジトリー?

★Mavenでは、mvnコマンドのオプションとして「ゴール」を指定して実行する
mvn ゴール 例:clean/test/install:install-file
「プラグイン名:」でプラグイン特有のゴールを指定できる。
http://maven.apache.org/plugins/index.html
いろいろできようね。。
全体像をつかまない。。。。


★プロジェクトをビルドする
cd test1
mvn package
==>bulid,compile,run testClass,
テスト結果が作成される、jarファイルも作成された!!
いろいろやってくれありがとうございます!
※packageはgoalではなく、phaseである。
プロジェクトのlifeCycleでいろんなphaseがある。package前のphaseは全て実行される。
(package?jarファイルを作成すること?)
validate
compile
test
package
intergration-test
verfify
install
deploy
clean
site
------
phaseの下goalがあるの感じ。ディフォルトのgoalもある!


★pom.xml
・下記の座標でプロジェクトを管理する
groupId-->URL/Package
artifactId-->そのグループ中のID
version-->
name-->必須ではない
プロジェクト管理なので、実際のCodeと関係がない。
pomで管理対象を設定するので、pomを修正すれば良い。

★eclipseに導入。。。

mvn eclipse:eclipse
==>windowsでuserのディレクトリの下で、権限の問題でいろいろうまくいかない!!
Cではなく、別のところにしよう。。

★echo %M2_HOME%
=>windowsで

★====>必要な時、plugInを検索して使う。

Why maven



Why maven?
除了写源代,我每天有相当一部分时间花在了编译、运行测试、生成文档、打包和部署等烦琐且不起眼的工作上,是构建
一直在不停地找避免重复的方法。设计的重复、编码的重复、文档的重复,
当然有构建的重复。Maven最大化地消除了构建的重复,抽象了构建生命周期,并且为绝大部分的构建任提供了已实现的插件,我不再需要定义过程,甚至不需要再去实现这程中的一些任
简单的例子是测试,我没必要告Maven测试,更不需要告Maven如何运行测试,只需要遵循Maven写好测试用例,当我运行构建的候,测试便会自运行

个开源的年代里,几乎任何Java用都会借用一些第三方的开源类库类库都可通的方式引入到目中来。随着依的增多,版本不一致、版本冲突、依问题都会接踵而来。手工解决问题是十分枯燥的,幸运的是Maven提供了一个秀的解决方案,它通一个坐准确地定位每一个构件(artifact),也就是通Maven找到任何一个Java类库(如jar文件)。Maven给这类库世界引入了经纬们变得有秩序,于是我可以借助它来有序地管理依松地解决那些繁的依赖问题

只要定位了坐Maven就能帮我,省去了手工劳动
★これみたいな物!
使用脚本建立高度自定的构建系就像买组PC,耗时费力,果也不一定很好。当然,你可以享受从无到有的趣,但恐怕实际项目中无法你那么多时间。使用Maven就像购买品牌PC,省省力,并能得到成熟的构建系能得到来自于Maven社区的大量支持。

MAVEN VS IDE
IDE能大大提高开效率。当前主流的IDEEclipseNetBeans等都提供了大的文本编辑调试甚至重构功能。然使用简单的文本编辑器和命令行也能完成大部分开工作,但很少有人愿意那做。然而,IDE是有其天生缺陷的: 
 IDE大量的手工操作。编译测试、代生成等工作都是相互独立的,很
完成所有工作。手工劳动往往意味着低效,意味着容易出   
目中一所有的IDE配置,每个人都有自己的喜好。也正是由于个原因,一个在机器A上可以成功运行的任,到了机器BIDE中可能就会失 
们应该合理利用IDE,而不是多地依它。于构建这样的任,在IDE中一次次地点是愚蠢的行Maven方面的家,而且主流IDE都集成了Maven


MAVEN VS ANT
MakeAnt也都是程式的,开式地指定每一个目,以及完成所需要行的任针对每一个目,开者都需要重新程,里其实隐含着很大的重复。Maven是声明式的,目构建程和程各个段所需的工作都由插件实现,并且大部分插件都是成的,开者只需要声明目的基本元素,Maven行内置的、完整的构建程。在很大程度上消除了重复。 
Ant是没有依管理的,所以很一段时间Ant都不得不手工管理依是一个令人疼的问题。幸运的是,Ant户现在可以借助Ivy管理依。而Maven,依管理是理所当然的,Maven内置了依管理,更有一个可能有全世界最多Java开源件包的中央仓库Maven须进行任何配置就可以直接享用

Maven真比自己的“范化Ant”大?其他不知道自己只是在重新子,Maven有一大把成的插件,全世界都在用,你自己不用写任何代 什么没有人“我自己写的代最灵活,所以我不用Spring,我自己实现IoC;我不用Hibernate,我自己封装JDBC”