LoginSignup
3
1

More than 3 years have passed since last update.

HerokuにBasic認証の導入【Spring Framework】

Last updated at Posted at 2020-06-28

成果物

スクリーンショット 2020-06-28 17.22.18.png

準備

Heroku公式ドキュメント

↑のHeroku公式ドキュメントにしたがって、Herokuデプロイの準備をすること。

pom.xml
・・・
<packaging>war</packaging>
・・・
<dependencies>
・・・
</dependencies>
<build>
    ...
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals><goal>copy</goal></goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.heroku</groupId>
                                <artifactId>webapp-runner</artifactId>
                                <version>9.0.30.0</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

※プロジェクトがwarでコンパイルされていること

Procfile
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT --enable-basic-auth --basic-auth-user [ユーザー名] --basic-auth-pw [パスワード] target/*.war
3
1
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
3
1