6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dropwizard 0.8.0 への移行でおそらく最初につまづく点

6
Last updated at Posted at 2015-03-16

Dropwizard 0.8.0 から ViewBundle のコンストラクタが変更になっている。
そのため 0.7.x からそのまま移行しようとした際にまずはつまづくことになる。
(別エントリのシンプルチャットサーバーではビューを使っていないため問題が顕在化していない)

2015/06/25 0.8.1の件を追記

Dropwizard 0.9.x系の開発が進む中、自分のアプリケーションを0.8.0から0.8.1ベースに置き換えようとして引っかかった点。

  • bundleの関連づけの記述が0.7.x系と同じスタイルに戻っている

要は下の記述のうち、旧版として書いているスタイルのままでよいと言うこと。
最初から同じにしておいてほしかった気もするが…

対象はアプリケーションメインクラスの initialize メソッド内の記述。
旧版では

@Override
public void initialize(Bootstrap<ExampleAppConfiguration> bootstrap) {
	bootstrap.addBundle(new ViewBundle());
	bootstrap.addBundle(new AssetsBundle());
}

としていた箇所が0.8.0では次のようになる。(下の事例はテンプレートエンジンに freemarker を使っているので拡張子に ftl を指定している)

@Override
public void initialize(Bootstrap<ExampleAppConfiguration> bootstrap) {
	bootstrap.addBundle(new ViewBundle<ExampleAppConfiguration>() {
		@Override
		public ImmutableMap<String, ImmutableMap<String, String>> getViewConfiguration(ExampleAppConfiguration config) {
			ImmutableMap.Builder<String, ImmutableMap<String, String>> builder = ImmutableMap.builder();
			builder.put(".ftl", ImmutableMap.<String, String> of());
			return builder.build();
		}
	});
	bootstrap.addBundle(new AssetsBundle());
}

他には以下のような対応が必要になるはず。

  • commons-lang3 へ更新されていることによる必要な対応
  • import 文の書き換え
  • escapeJavaScript(String) を escapeEcmaScript(String) へ書き換え
  • RandomUtils が使えなくなるので別の手段へ切り替え
  • bson4jackson 2.4 を使っている場合の対応
  • bson4jackson が参照する jackson は2.4 系なので dependency ブロック内で「jackson-core」「jackson-annotations」「jackson-databind」を exclude する
  • jersey-media-multipart を ver1 系統から ver2 系へ更新 ~~~すると引数の受け方を変える必要がある~~~
  • アプリケーションクラスの run メソッド内へ「environment.jersey().register(MultiPartFeature.class);」を追記
2015/0318

jersey-media-multipartを使用するときの対応を盛大に勘違いしていた。修正。

参考リンク

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?