Spring boot 使用 Webjars
https://www.webjars.org/ 介绍整合前端静态资源
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.4.1-1</version>
</dependency>
在springboot 项目static 目录下新建一个index.html 页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>deyou</title>
<link rel="stylesheet" href="webjars/bootstrap/4.4.1-1/css/bootstrap.min.css" />
<script src="webjars/jquery/3.4.1/jquery.min.js"></script>
<script src="webjars/bootstrap/4.4.1-1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container"><br>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">X</a>
Hello, <strong>De you !</strong>
</div>
</div>
<script>
alert($('.close').attr('herf'));
</script>
</body>
</html>
启动项目。访问
和 http://localhost:8080/webjars/jquery/3.4.1/jquery.min.js