Giter VIP home page Giter VIP logo

spring-boot2-thymeleaf-polling's Introduction

spring-boot2-thymeleaf-polling

Sample Web App on Heroku

System Administrator Page

https://spring-boot2-polling.herokuapp.com/home

User Page

https://spring-boot2-polling.herokuapp.com/questionnaire/top

Spring Boot2アプリの起動

1. Mavenを利用する場合

PostgreSQLの起動

デフォルトスキーマpublicを設定する必要あり。 以下のコマンドで、日本語の文字コードを設定したpostgreSQLのDockerイメージ生成・起動を行う(テスト用なのでデータの永続化は行っていない)。

docker build -t postgres-dev -f env/postgresql/Dockerfile env/postgresql/
docker run -it --rm --name postgres-dev -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password -e POSTGRES_DB=questionnairedb -p 5433:5432 -d postgres-dev

以下のコマンドで、postgreSQLのデータベースが生成されているかチェック。

docker exec -it postgres-dev psql -U postgres
postgres#=\l

MariaDBの起動

文字コードをutf8mb4_unicode_ciに設定する必要あり。

docker run -it --rm --name mariadb-dev -e MYSQL_DATABASE=questionnairedb_test -e MYSQL_ROOT_PASSWORD=password -p 3307:3306 -d mariadb:10.3.10 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

MySQLの起動

docker run -it --rm --name mysql-dev -e MYSQL_DATABASE=questionnairedb_test -e MYSQL_ROOT_PASSWORD=password -p 3307:3306 -d mysql:8.0.15 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

Spring bootアプリの起動

以下のコマンドを実行し、Webアプリケーションをビルド・起動する。

# For MacOS, Linux
./mvnw spring-boot:run

# For Windows
mvnw.cmd spring-boot:run

WAR・JARパッケージを作成する

# For MacOS, Linux
./mvnw clean package

# For Windows
mvnw.cmd -Dmaven.test.skip=true clean package

TomcatサーバでのWARファイルのサイズ制限でエラーになることがあるので、conf/server.xmlに以下の設定を追加する。

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
           maxPostSize="70428800" />

もしくは、/webapps/manager/WEB-INF/web.xmlに、

<multipart-config>
   <max-file-size>80428800</max-file-size>
   <max-request-size>80428800</max-request-size>
   <file-size-threshold>0</file-size-threshold>
</multipart-config>

2. jibを使ったSpring Bootアプリの起動

2.1. PostgreSQLを使う場合

まず、application.ymlファイルでProfileをpostgres-dockerに設定する。
次に、以下のコマンドを実行し、docker-composeにより、DBサーバとAPPサーバをDockerコンテナ上で起動する。

# PostgreSQLのDockerイメージの作成
docker build -t postgres-dev -f env/postgresql/Dockerfile env/postgresql/

# Spring bootアプリ実行環境用のDockerイメージの作成
mvn compile jib:dockerBuild

# docker-composeの起動
cd ./env/postgresql
docker-compose up -d

2.2. MySQLを使う場合

まず、application.ymlファイルでProfileをmysql-dockerに設定する。
次に、以下のコマンドを実行し、docker-composeにより、DBサーバとAPPサーバをDockerコンテナ上で起動する。

# Spring bootアプリ実行環境用のDockerイメージの作成
mvn compile jib:dockerBuild

# docker-composeの起動
cd ./env/mysql
docker-compose up -d

Demo

spring-boot2-thymeleaf-polling's People

Contributors

imamachi-n avatar

Watchers

James Cloos avatar  avatar

Forkers

tamtamu-spring

spring-boot2-thymeleaf-polling's Issues

アンケートフォーム画面のバグ

アンケートフォーム画面において、未入力があった場合にページがリロードされたときに、コメント回答欄に書いてあった内容が消えてしまう。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.