LoginSignup
4
1

More than 1 year has passed since last update.

java開発でbootstrap導入の場合、以下の3つの方法がある。

  • CDNのURLを貼り付ける ※公式サイトの「Getting Stared (v.4.6)」参照
  • bootstrapからダウンロードして配置する ※公式サイトの「Getting Stared (v.4.6)」からDownloadできる
  • WebJar for BootstrapをMVN Repositoryから取得 ※今回はこの方法の紹介

前提環境

  • Java 11
  • Spring Boot 2.5.2
  • Thymeleaf 3.0.12

導入方法

gradle

dependencies {
(省略)
    implementation 'org.webjars:jquery:3.5.0'
    implementation 'org.webjars:bootstrap:4.4.1-1'
(省略)
}

thymeleaf

<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" lang="ja">
<head>
<link th:href="@{/webjars/bootstrap/4.4.1-1/css/bootstrap.min.css}" rel="stylesheet"/>
</head>
<body>
    <script th:href="@{/webjars/jquery/3.5.0/js/jquery.min.js}"></script>
    <script th:href="@{/webjars/bootstrap/4.4.1-1/js/bootstrap.min.js}"></script>
</body>
</html>
4
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
4
1