Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在spring初始化器上使用bootstrap_Html_Spring_Intellij Idea_Jakarta Ee_Bootstrap 4 - Fatal编程技术网

Html 在spring初始化器上使用bootstrap

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

我在intellij中使用spring,我发现使用引导时出现问题。。我声明了对pom.xml的依赖关系,但在外部库中找不到它

<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'>

欢迎使用堆栈溢出!感谢您不仅链接到文档,而且提供了很好的解释以及代码示例。这是一篇很好的第一篇文章。