Не подтягиваются стили css в html
Подскажите пожалуйста. Не подтягиваются css стили и js скрыпты при запуске приложения на локальном сервере. А если отдельно файлы открывать через хром то работает как надо.
Так подтягиваю стили в html
<link th:src="@{static/js/vendor/bootstrap/bootstrap.min.css}" type="text/css" rel="stylesheet">
<link th:src="@{static/js/vendor/slick/slick.css}" type="text/css" rel="stylesheet">
<link th:src="@{static/js/vendor/swiper/swiper.min.css}" type="text/css">
<link th:src="@{static/js/vendor/magnificpopup/dist/magnific-popup.css}" type="text/css">
<link th:src="@{static/js/vendor/nouislider/nouislider.css}" type="text/css">
<link th:src="@{static/js/vendor/darktooltip/dist/darktooltip.css}" type="text/css">
Пробовал и через < href="..."> подтягивать, результат тот же. Если добавить rel="stylesheet" то в браузере в консоли получаю "...because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."
MVC конфиг
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
registry.addViewController("/news").setViewName("news");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/js/**")
.addResourceLocations("/resources/static/js/");
registry
.addResourceHandler("/css/**")
.addResourceLocations("/resources/static/css/");
registry
.addResourceHandler("/images/**")
.addResourceLocations("/resources/static/images/");
registry
.addResourceHandler("fonts/icomoon-reg/**")
.addResourceLocations("/resources/static/fonts/icomoon-reg/");
}
Пробовал пути прописывать множеством разных способов и абсолютный и относительный. Что то упускаю но сам не могу понять что именно. Думал еще что виноват спрингСекьюрити, убирал его и результат тот же. Пишу в idea. Вот pom.xml
<groupId>shop</groupId>
<artifactId>shop</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>shop Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
</parent>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<spring.boot.version>2.6.6</spring.boot.version>
</properties>
<dependencies>
<!-- SPRING -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- DB -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.3</version>
</dependency>
<!-- MAPSTRUCT -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</dependency>
<!-- SWAGGER -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<!-- other -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>shop</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>