treeコマンドのメモ(linuxでなくwindowsのdos窓で使えるtree)

・treeだけだとカレントディレクトリ以下のフォルダ構成を表示する。リカーシブでサブフォルダも表示する。
・サブフォルダのみの構造を知りたい時は引数にサブフォルダを指定する。
・/Aオプションはツリー文字にASCII文字を表示する
・/Fオプションはフォルダ内のファイルもすべて表示する。

サンプル

>tree
フォルダー パスの一覧: ボリューム Windows7_OS
ボリューム シリアル番号は 5CBC-0AB9 です
C:.
├─.settings
├─src
│ ├─main
│ │ └─java
│ │ └─testGroupId
│ └─test
│ └─java
│ └─testGroupId
└─target
├─classes
│ ├─META-INF
│ │ └─maven
│ │ └─testGroupId
│ │ └─testArtifactId
│ └─testGroupId
├─maven-archiver
├─surefire
├─surefire-reports
└─test-classes
└─testGroupId

>tree /F
フォルダー パスの一覧: ボリューム Windows7_OS
ボリューム シリアル番号は 5CBC-0AB9 です
C:.
│ .classpath
│ .project
│ pom.xml

├─.settings
│ org.eclipse.core.resources.prefs
│ org.eclipse.jdt.core.prefs
│ org.eclipse.m2e.core.prefs
│ org.eclipse.wst.common.project.facet.core.xml

├─src
│ ├─main
│ │ └─java
│ │ └─testGroupId
│ │ App.java
│ │
│ └─test
│ └─java
│ └─testGroupId
│ AppTest.java

└─target
│ testArtifactId-1.0-SNAPSHOT.jar

├─classes
│ ├─META-INF
│ │ │ MANIFEST.MF
│ │ │
│ │ └─maven
│ │ └─testGroupId
│ │ └─testArtifactId
│ │ pom.properties
│ │ pom.xml
│ │
│ └─testGroupId
│ App.class

├─maven-archiver
│ pom.properties

├─surefire
├─surefire-reports
│ TEST-testGroupId.AppTest.xml
│ testGroupId.AppTest.txt

└─test-classes
└─testGroupId
AppTest.class


>tree /A
フォルダー パスの一覧: ボリューム Windows7_OS
ボリューム シリアル番号は 5CBC-0AB9 です
C:.
+---.settings
+---src
| +---main
| | \---java
| | \---testGroupId
| \---test
| \---java
| \---testGroupId
\---target
+---classes
| +---META-INF
| | \---maven
| | \---testGroupId
| | \---testArtifactId
| \---testGroupId
+---maven-archiver
+---surefire
+---surefire-reports
\---test-classes
\---testGroupId

>tree target /F
フォルダー パスの一覧: ボリューム Windows7_OS
ボリューム シリアル番号は 5CBC-0AB9 です
C:\REPOS\TESTFRAMEWORK\MAVEN\TESTARTIFACTID\TARGET
│ testArtifactId-1.0-SNAPSHOT.jar

├─classes
│ ├─META-INF
│ │ │ MANIFEST.MF
│ │ │
│ │ └─maven
│ │ └─testGroupId
│ │ └─testArtifactId
│ │ pom.properties
│ │ pom.xml
│ │
│ └─testGroupId
│ App.class

├─maven-archiver
│ pom.properties

├─surefire
├─surefire-reports
│ TEST-testGroupId.AppTest.xml
│ testGroupId.AppTest.txt

└─test-classes
└─testGroupId
AppTest.class
mavenでspringプロジェクト作ってみたときのメモ書き。

■参考サイト
MavenとSpringFrameworkを併用するAdd
Obtaining Spring 3 Artifacts with Maven

■maven参考本
Apache Maven 3クックブック Javaソフトウェア開発のための特選レシピ集/アスキー・メディアワークス
¥2,520
Amazon.co.jp




・プロジェクト雛形作成。プロジェクト名はTestMavenSpringapp
>mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DartifactId=TestMavenSpringapp -DgroupId=net.hoge.spring.maven

・pom.xmlを下のように作成

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.hoge.spring.maven</groupId>
<artifactId>TestMavenSpringapp</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>TestMavenSpringapp</name>
<url>http://maven.apache.org</url>
<properties>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>


<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
</dependency>

</dependencies>


<build>
<finalName>TestMavenSpringapp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

</plugins>
</build>


</project>

・src/main/resourcesソースフォルダを作成し、その下にcontext.xmlを作る

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/mvc/spring-tx.xsd">

<context:component-scan base-package="net.hoge.spring.maven.services"/>
 <context:component-scan base-package="net.hoge.spring.maven"/>
</beans>

・net.hoge.spring.maven.servicesパッケージにMyServiceOneを作成する。ただ、ここでorg.springframework.stereotype.Serviceクラスがimportできない。で、pom.xmlのdependencyで書いたjarが全然読こめてないみたい・・・eclipseの依存関係タブを見れば読み込んでいるみたいなんだけど。いろいろ試してみたけど断念。急ぎじゃないし。そのうちいつか、というメモ

package net.hoge.spring.maven.services;

import org.springframework.stereotype.Service;

@Service("myServiceOne")
public class MyServiceOne {
public String getA() {
return "A";
}
}

■org.springframework.stereotype.Serviceクラスはどのjar

あと、org.springframework.stereotype.Serviceクラスがどのjarクラスにはいっているんだろう?って思って調べたんだけど、maven repositoryが一番わかりやすい。めぼしいartifactIdに狙いをつけて(この場合はspring-context)、そのページを見ると、下の方がpackageという項目があって、そこにクラス一覧が書いてある。

Spring Context 3.0.5.RELEASE(maven repository)

あとはこんなサイトも。

Actifactory binary repo Download org.springframework.context-3.0.4.RELEASE.jar
mavenでwebプロジェクト作成~jetty上で起動するまでのメモ書き。

■プロジェクト作成
>mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp -DartifactId=TestMavenWebapp -DgroupId=net.hoge.webapp -Dpackage=ne
t.hoge.webapp

プロジェクト名はTestMavenWebapp。

TestMavenWebappディレクトリに移動してpom.xmlを下のように編集。pluginにmaven-compiler-plugin、jetty-maven-pluginを追加。コンテナにはjettyを使う。コマンドラインからビルドでwar作って簡単にデプロイするため。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.hoge.webapp</groupId>
<artifactId>TestMavenWebapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>TestMavenWebapp Maven Webapp</name>
<url>http://maven.apache.org</url>

<properties>
<jettyVersion>7.2.0.v20101020</jettyVersion>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>TestMavenWebapp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jettyVersion}</version>
</plugin>

</plugins>
</build>

</project>

■続いてビルド~インストール
>mvn install

targetディレクトリ下にwarファイルができる

■jettyで起動
pom.xmlでjettyのプラグインは設定済み。ゴールはjetty:runで実行

>mvn jetty:run

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TestMavenWebapp Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> jetty-maven-plugin:7.2.0.v20101020:run (default-cli) @ TestMavenWebapp >>>
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ TestMavenWebapp ---
[debug] execute contextualize
[WARNING] Using platform encoding (MS932 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ TestMavenWebapp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ TestMavenWebapp ---
[debug] execute contextualize
[WARNING] Using platform encoding (MS932 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ TestMavenWebapp ---
[INFO] No sources to compile
[INFO]
[INFO] <<< jetty-maven-plugin:7.2.0.v20101020:run (default-cli) @ TestMavenWebapp <<<
[INFO]
[INFO] --- jetty-maven-plugin:7.2.0.v20101020:run (default-cli) @ TestMavenWebapp ---
[INFO] Configuring Jetty for project: TestMavenWebapp Maven Webapp
[INFO] webAppSourceDirectory C:\TestMavenWebapp\src\main\webapp does not exist. Defaulting to C:\TestMavenWebapp\src\main\webapp

[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\TestMavenWebapp\target\classes
[INFO] Context path = /
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:/C:/TestMavenWebapp/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = C:\TestMavenWebapp\src\main\webapp
[INFO] Starting jetty 7.2.0.v20101020 ...
2013-10-03 21:25:48.445:INFO::jetty-7.2.0.v20101020
2013-10-03 21:25:48.567:INFO::No Transaction manager found - if your webapp requires one, please configure one.
2013-10-03 21:25:48.717:INFO::Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server

Context pathが/になっている。http://localhost:8080にアクセスしたらhello worldが表示された(デフォルトのindex.jsp)。他のサンプルをみたらhttp://localhost:8080/プロジェクト名 とかなんだけど…設定でいくらでもなる問題。

上のゴールjetty:runは開発用らしい。他には「mvn jetty:run-exploded」「mvn jetty:run-war」とかがある。


maven参考本,おすすめ本

Apache Maven 3クックブック Javaソフトウェア開発のための特選レシピ集/アスキー・メディアワークス
¥2,520
Amazon.co.jp




windowsのタスク一覧を表示、プロセスIDを指定してタスクを削除するコマンドのメモ書き。linuxのps aux,killみたいな感じ。cygwin入れてps,kilを試してみたけどだめだったから・・・

タスク一覧を表示するには「tasklist」。タスク名、プロセスID、他が表示される。タスク名をプロセスIDを指定して削除したい場合は「>Taskkill /PID 14340 /F」。14340はプロセスID。