我想在我的服务 webjars Bootstrap 中使用。
我添加了依赖
compile group: 'org.webjars', name: 'bootstrap', version: '4.0.0-alpha.6-1'
我注册源
registry
.addResourceHandler("/webjars/**")
.addResourceLocations("/webjars/");
我在 thymeleaf 中使用 Bootstrap css
<link rel="stylesheet" th:href="@{webjars/bootstrap/4.0.0-alpha.6-1/css/bootstrap.min.css}">
并且 Bootstrap 根本不起作用。没有元素。这个服务怎么没有看到 Bootstrap css 文件?在我使用的元素中,例如 Spring Security。会不会有什么影响?修理它是否值得? webjars 文件和“resource”文件夹中这样一个普通的 css 文件之间的速度是多少?
最佳答案
要将 Bootstrap 添加为 webjar,请将以下内容添加到 build.gradle:
dependencies {
...
compile 'org.webjars:bootstrap:4.1.3'
}
并将其附加到 html 模板:
<body>
<script src="/webjars/bootstrap/4.1.3/js"></script>
...
</body>
关于css - Spring 和 Gradle - 添加到元素 WebJars Bootstrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43821396/