2
13

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.

SpringBootでwarデプロイする際のgradle設定

Posted at

概要

springbootのembedtomcatは便利なのだが
本番環境等で据え置きのtomcatに乗っける要件が多々ある。

springbootが用意するwarデプロイ方法を使えばよいのだが
springboot-starter-web を依存関係に含んでいると
spring-boot-starter-tomcatorg.apache.tomcat.embed を連れてきてしまう。

あっても問題ないのだが本番リリース時に使わないembedtomcatライブラリは外したい。
しかし開発時はtomcat面倒なのでembedtomcatを使いたい。
ということを実現する方法。

手順

build.gradle を以下のようにしてやればOK

dependencies {
    // starter-webからtomcatを外す
    compile(group: 'org.springframework.boot', name: 'spring-boot-starter-web') {
        exclude(module: 'spring-boot-starter-tomcat')
        exclude(group: 'org.apache.tomcat.embed')
    }
        // providedの時は逆にstarter-tomcatを入れる
    providedCompile(group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat')

    }

}

2
13
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
2
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?