Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What are the problem?

posted at

Organization

Gradleでbootstrap導入

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>
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
1
Help us understand the problem. What are the problem?