Html 在spring初始化器上使用bootstrap
我在intellij中使用spring,我发现使用引导时出现问题。。我声明了对pom.xml的依赖关系,但在外部库中找不到它Html 在spring初始化器上使用bootstrap,html,spring,intellij-idea,jakarta-ee,bootstrap-4,Html,Spring,Intellij Idea,Jakarta Ee,Bootstrap 4,我在intellij中使用spring,我发现使用引导时出现问题。。我声明了对pom.xml的依赖关系,但在外部库中找不到它 <dependency> <groupId>org.webjars</groupId> <artifactId>bootstrap</artifactId> <version>4.5.0</version> </dependen
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.5.0</version>
</dependency>
org.webjars
独自创立
4.5.0
我不知道写什么好
<link rel="stylesheet" type="text/css" href="">
WebJars在如何将其与Spring结合使用方面做得非常好。Web依赖项可在类路径中找到,网址为META-INF/resources/webjars/
。您需要添加一个资源处理程序,让Spring在所需位置为依赖项提供服务:
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
然后,可以在资源处理程序中指定的资源位置包含引用资源:
<link rel='stylesheet' href='/webjars/bootstrap/4.5.0/css/bootstrap.min.css'>
欢迎使用堆栈溢出!感谢您不仅链接到文档,而且提供了很好的解释以及代码示例。这是一篇很好的第一篇文章。