fc2ブログ

2011-12-26(Mon)

restEasyのSpring化(2)

Springを使う目的はSpringの宣言的トランザクションを使ってみたいためです。
今回は、project/src/main/resourcesフォルダについて以下のことをします。
①springmvc-resteasy.xmlの作成
②springmvc-servlet.xmlの作成
③datasource.propertiesの作成
④hibernate.propertiesの作成

①springmvc-resteasy.xmlの作成
restEasyのDocument(http://docs.jboss.org/resteasy/docs/2.3.0.GA/userguide/html/RESTEasy_Spring_Integration.html)
を見てみても、中途半端でわからない。
http://resteasy.svn.sourceforge.net/viewvc/resteasy/trunk/jaxrs/resteasy-spring/src/main/resources/springmvc-resteasy.xml?view=markup
を見ると、resteasy-springにあることがわかる。
maven central(http://search.maven.org/)からパッケージごとダウンロードして中からspringmvc-resteasy.xmlを抜き取り
resourcesフォルダにおく。

②springmvc-servlet.xmlの作成
ここで重要なのはspringmvc-resteasy.xmlを参照するよう設定すること。

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
">
<context:component-scan base-package="service.api.user" />
<context:annotation-config />
<import resource="classpath:springmvc-resteasy.xml" />

<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>

</beans>


③datasource.propertiesの作成
これはhibernate.cfg.xmlからコピペすればよい。

dataSource.driverClassName = org.postgresql.Driver
dataSource.username = hoge
dataSource.password = hogehoge
dataSource.hostname = xxx.xx.xxx.xx:5432
dataSource.dbname = hogedb
dataSource.url = jdbc:postgresql://${dataSource.hostname}/${dataSource.dbname}


④hibernate.propertiesの作成
これも簡単。

hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
hibernate.connection.driver_class org.postgresql.Driver
hibernate.connection.url jdbc:postgresql://xxx.xx.xxx.xx:5432/hogedb
hibernate.connection.username hoge
hibernate.connection.password hogehoge


今日はここまで。
参考:


関連記事
スポンサーサイト



コメントの投稿

管理者にだけ表示を許可する

コメント

プロフィール

kumagonjp2

Author:kumagonjp2
Python,Django,R,Mongo,MySQL,Struts,Spring,データマイニングなどサーバー関係のメモを残していきます。

最新記事
最新コメント
最新トラックバック
月別アーカイブ
カテゴリ
雪が3Dで降るブログパーツ ver2

マウスで見る方向変えられます

検索フォーム
RSSリンクの表示
リンク
ブロとも申請フォーム

この人とブロともになる

QRコード
QR