前提・実現したいこと
Spring Boot + thymeleaf でWEBアプリを作成しています。
プロジェクト管理ツールにはMavanを利用しています。
作成しているWEBアプリでbootstrap.js(3.3.7)を利用したく、設定を行っています。
発生している問題・エラーメッセージ
WEBアプリは動作はするのですが、以下のように実行時にwebjars内のファイルが見つからないようで404となります。
※実行時のコンソールログ GET http://localhost:8080/webjars/bootstrap/3.3.7/js/bootstrap.min.js 404 () GET http://localhost:8080/webjars/bootstrap/3.3.7/css/bootstrap.min.css 404 ()
詳細後述しますが、表題の通りbootstrapのバージョンが3.3.7である場合はダメで、例えば3.3.1だと正常に動作します。
該当のソースコード
関係すると思われる箇所のみ抜粋しますが、必要であれば追記します。
HTML
1 2 <link rel="stylesheet" media="all" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}" /> 3 <script type="text/javascript" th:src="@{/webjars/jquery/3.3.1/jquery.min.js}"></script> 4 <script type="text/javascript" th:src="@{/webjars/bootstrap/3.3.7/js/bootstrap.min.js}"></script> 5
pom.xml
XML
1 2 <!-- https://mvnrepository.com/artifact/org.webjars/bootstrap --> 3 <dependency> 4 <groupId>org.webjars</groupId> 5 <artifactId>bootstrap</artifactId> 6 <version>3.3.7</version> 7 </dependency> 8 9 <!-- https://mvnrepository.com/artifact/org.webjars/jquery --> 10 <dependency> 11 <groupId>org.webjars</groupId> 12 <artifactId>jquery</artifactId> 13 <version>3.3.1</version> 14 </dependency> 15
試したこと
org.webjars.bootstrapのバージョンを3.3.1にすると動作します。
いくつか試してみましたが、以下のような結果となっています。
〇3.3.1
〇3.3.2
〇3.3.4
〇3.3.5
×3.3.6
×3.3.7
またjQueryも読み込めているため、まるっきり動作していないというわけでもなさそうなのですが・・
補足情報(FW/ツールのバージョンなど)
色々と調査したところ、Spring Bootがwebjars内の静的ファイルを/webjars/...で参照できるようにしているのはWebMvcAutoConfigureのaddResourceHandlersということは把握しており、デバッグもしてみたのですがよく分からず。現状手詰まりです。
このあたりを調べてみてはどうかというアドバイスだけでも頂けると助かります。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/23 05:44
退会済みユーザー
2018/07/23 06:41
2018/07/23 07:23