properly serve public folder

This commit is contained in:
MiniDigger 2020-07-11 17:52:48 +02:00
parent 9aa057312d
commit aa9f3d4991
2 changed files with 21 additions and 1 deletions

View File

@ -2,11 +2,16 @@ package me.minidigger.hangar.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import java.util.concurrent.TimeUnit;
@Configuration
public class MvcConfig {
public class MvcConfig implements WebMvcConfigurer {
@Bean
public FreeMarkerViewResolver freemarkerViewResolver() {
@ -23,4 +28,11 @@ public class MvcConfig {
freeMarkerConfigurer.setTemplateLoaderPath("classpath:templates");
return freeMarkerConfigurer;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/assets/**")
.addResourceLocations("classpath:/public/")
.setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS));
}
}

View File

@ -1,4 +1,12 @@
###########
# General #
###########
server.port=8080
spring.mvc.static-path-pattern=/content/**
############
# DataBase #
############
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/hangar