Skip to content

Commit 50def8f

Browse files
sdeleuzeelhadramy
authored andcommitted
Use WebJars versioned URLs (#1099)
In order to improve efficiency (see spring-projects/spring-framework#27619) and allow native image compatibility, this commit uses WebJars versioned URLs which are supported out of the box on Spring Boot via /META-INF/resources default resource location configuration, removing the need to use webjars-locator-core dependency and WebJarsResourceResolver. I have been able to measure a consistent 5% startup time improvement on the JVM with that simple change on my local machine.
1 parent b6146d0 commit 50def8f

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ dependencies {
2525
implementation 'org.springframework.boot:spring-boot-starter-validation'
2626
implementation 'javax.cache:cache-api'
2727
runtimeOnly 'org.springframework.boot:spring-boot-starter-actuator'
28-
runtimeOnly 'org.webjars:webjars-locator-core'
2928
runtimeOnly "org.webjars.npm:bootstrap:${webjarsBootstrapVersion}"
3029
runtimeOnly "org.webjars.npm:font-awesome:${webjarsFontawesomeVersion}"
3130
runtimeOnly 'org.ehcache:ehcache'

pom.xml

-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@
8989
</dependency>
9090

9191
<!-- webjars -->
92-
<dependency>
93-
<groupId>org.webjars</groupId>
94-
<artifactId>webjars-locator-core</artifactId>
95-
</dependency>
9692
<dependency>
9793
<groupId>org.webjars.npm</groupId>
9894
<artifactId>bootstrap</artifactId>

src/main/resources/templates/fragments/layout.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
1818
<![endif]-->
1919

20-
<link th:href="@{/webjars/font-awesome/css/font-awesome.min.css}" rel="stylesheet">
20+
<link th:href="@{/webjars/font-awesome/4.7.0/css/font-awesome.min.css}" rel="stylesheet">
2121
<link rel="stylesheet" th:href="@{/resources/css/petclinic.css}" />
2222

2323
</head>
@@ -87,7 +87,7 @@
8787
</div>
8888
</div>
8989

90-
<script th:src="@{/webjars/bootstrap/dist/js/bootstrap.bundle.min.js}"></script>
90+
<script th:src="@{/webjars/bootstrap/5.1.3/dist/js/bootstrap.bundle.min.js}"></script>
9191

9292
</body>
9393

0 commit comments

Comments
 (0)