spring tool suiteでspringのメモ。pleiades4.3もspringのプラグインが最初から入っていて一緒。


springプロジェクトを選択して次へ⇒spring mvc projectを選択してプロジェクト名を入力して作成する。この時、top-level packageを求められる。プロジェクトを右クリック⇒property⇒spring⇒dependeny management⇒「automatically update dependency from maven pom.xml」にチェックボックスがある。

これで実行でサーバ上から実行をすれば、HomeController.javaの"/"が表示される。あと、mavenからinstallを実行してwarも作れる。でも、いろいろやっていると、サーバ上から実行はできるけど、mvn installがいつのまにかできなくなってた・・・まめにmvenでインストールした方がいい。めんどくせぇ・・・ちなみにmvn installで出たエラーログは↓

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project myapp: There are test failures.
[ERROR]
[ERROR] Please refer to C:\pleiades43\workspace\HogeProject\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[



こちら「Aspectjの@Before、@Afterを使ってメソッド前後にログ出力を入れる 」を参考にしてspring aopを試してみたら、下のエラーが出た。

java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
	org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getPointcut(ReflectiveAspectJAdvisorFactory.java:145)
	org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvisor(ReflectiveAspectJAdvisorFactory.java:130)
	org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory$1.doWith(ReflectiveAspectJAdvisorFactory.java:74)
	org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:473)
	org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:451)
	org.springframe

java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldExceptionでググったら、
overflowのサイト「missing spring aop library is sts 」を見つけた。

pom.xmlファイルに下を追加。これで解決しました。

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.11</version>
</dependency>

・参考
spring aopのexecutionの記述方法について
■java spring frameworkおすすめ本の紹介
SpringによるWebアプリケーションスーパーサンプル 第2版/ソフトバンククリエイティブ
¥3,990
Amazon.co.jp

Spring3入門 ――Javaフレームワーク・より良い設計とアーキテクチャ/技術評論社
¥4,095
Amazon.co.jp


■springの日本語文字化け対策
web.xmlやtomcatの場合はserver.xml

【springMVC】ブラウザで文字化けした時の対応方法