Refactor project structure and update configurations for improved resource handling

This commit is contained in:
liosha84
2025-06-28 21:15:08 +03:00
parent 5dc79438b7
commit 5fce34dfb8
12 changed files with 63 additions and 31 deletions
@@ -2,10 +2,13 @@ package com.jambotronGroup.jambotron.configuretions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/*
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
@Value("${spring.resources.static-locations}")
String resourceLocations;
@@ -13,7 +16,10 @@ public class MvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//registry.addResourceHandler("/public/**").addResourceLocations(resourceLocations);
// registry.addResourceHandler("/media/**").addResourceLocations("resources/main/public/media/");
registry.addResourceHandler("/**").addResourceLocations("classpath:/resources/");
//registry.
registry.addResourceHandler("/media/**").addResourceLocations("resources/main/public/media/");
}
}
}*/
@@ -15,7 +15,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
/*
@ControllerAdvice
public class NotFoundHandler {
@Value("${spa.default-file}")
@@ -0,0 +1,12 @@
package com.jambotronGroup.jambotron.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/*@Controller
public class RedirectController {
@RequestMapping(value = "/{path:[^\\.]*}")
public String redirect() {
return "forward:/index.html";
}
}*/
@@ -106,6 +106,7 @@ public class WebSecurityConfig {// extends WebSecurityConfigurerAdapter {
auth.requestMatchers("/api/auth/**").permitAll()
.requestMatchers("/*", "/home", "/resources/**").permitAll()
.requestMatchers("/resources/public/media/**").permitAll()
.requestMatchers("/resources/public/browser/**").permitAll()
.requestMatchers("/media/**").permitAll()
.requestMatchers("/api/test/**").permitAll()
.requestMatchers("/api/tutorials").permitAll()
+10 -6
View File
@@ -29,10 +29,12 @@ spring.mvc.throw-exception-if-no-handler-found=true
# Disable the default mappings
#spring.resources.add-mappings=false
spring.resources.static-locations=classpath:/public
spring.resources.cache.period=31557600s # 1 year if you want
spa.default-file=classpath:/public/browser/index.html
# UI(index.html) location
#spring.resources.static-locations=classpath:/public/browser/
#
#spring.resources.cache.period=31557600s # 1 year if you want
#spa.default-file=classpath:/public/browser/index.html
#
spring.docker.compose.file=../Docker/docker-compose.yml
@@ -44,5 +46,7 @@ spring.flyway.password=postgrespw
spring.flyway.url=jdbc:postgresql://localhost:5432/jambotronDB
spring.ai.zhipuai.base-url=https://open.bigmodel.cn/api/paas/v3
spring.ai.zhipuai.api-key = 628447c8c65845a48a7226391464a2ea.Dw8ci6TiW0BRF5LI
//spring.ai.zhipuai.base-url=https://open.bigmodel.cn/api/paas/v3
//spring.ai.zhipuai.api-key = 628447c8c65845a48a7226391464a2ea.Dw8ci6TiW0BRF5LI