LoginSignup
7
3

More than 5 years have passed since last update.

spring boot で Herokuへデプロイ

Posted at

spring boot の設定

resources配下にsystem.propertiesを作成

javaのバージョンを指定
java.runtime.version=1.8

アプリケーションのプロジェクトフォルダ配下にProcfileを作成

起動時の設定を指定
web: java -Dserver.port=$PORT -jar target/*.jar --server.port=$PORT --spring.profiles.active=heroku

Herokuにデプロイするまでの手順

デプロイしたいアプリのフォルダに移動

cd アプリのディレクトリ

gitにコミットまで行う

git init (初期化)
git add * (追加)
git commit -m 'first commit' (コミット)

herokuにログイン

heroku login
メールアドレスとパスワードを聞かれるので入力。

herokuにアプリを作成

heroku create アプリ名 (アプリ名を入力しなけかったら自動で作成される)

herokuにpush

git push heoku master

アプリの起動

heroku open

Herokuに作成したアプリの一覧を確認

heroku list

ログを確認

heroku logs --tail --app アプリ名

うまくいかなかったこと

Herokuにデプロイした際に
[ERROR] Failed to execute goal on project hbase-binding: Could not resolve dependenciesみたいなエラーが出てアプリがうまく起動できなかった。

原因

ググってみると.m2/repository配下に古いmavenプロジェクトが残っている時に起こるらしい。
というか、gitにcommitする際に.mvn配下のソースもcommitしていたのがそもそもの原因。
念のために.gitignoreに.mvnを追加し、
gitリポジトリを新しく作り直して、再度上記の手順でやるとうまくいった。

7
3
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
7
3