Skip to content

Commit

Permalink
Upgrade to Spring Boot 3
Browse files Browse the repository at this point in the history
  • Loading branch information
bbalganjjm committed Nov 17, 2023
1 parent e7b5fe1 commit f668600
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 134 deletions.
19 changes: 13 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<version>3.1.2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>17</java.version>
</properties>

<profiles>
Expand Down Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -90,7 +90,7 @@
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
<version>1.5</version>
</dependency>

<dependency>
Expand All @@ -114,13 +114,20 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>

</dependencies>

<build>
<defaultGoal>install</defaultGoal>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/common/app/file/XlsxToJSONController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.Locale;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Cell;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/common/aspects/VOFilterAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import java.util.List;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
Expand Down
60 changes: 37 additions & 23 deletions src/main/java/common/config/WebMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
* @author KIM HWANG MAN( bbalganjjm@gmail.com )
* @since 2020.11.25
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import common.exception.ExceptionResolver;
import common.filter.XSSFilter;
import common.interceptor.PermissionCheckInterceptor;
import common.views.FileView;
import common.views.XlsxStreamingView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.accept.ContentNegotiationManagerFactoryBean;
import org.springframework.web.accept.PathExtensionContentNegotiationStrategy;
import org.springframework.web.filter.ShallowEtagHeaderFilter;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
Expand All @@ -36,22 +36,21 @@
import org.springframework.web.servlet.view.BeanNameViewResolver;
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.spring6.SpringTemplateEngine;
import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring6.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;

import common.exception.ExceptionResolver;
import common.filter.XSSFilter;
import common.interceptor.PermissionCheckInterceptor;
import common.views.FileView;
import common.views.XlsxStreamingView;
import java.util.*;

@Configuration
@ComponentScan(basePackages = { "common" }, includeFilters = {
@ComponentScan(basePackages = { "common", "kr.goldmandata.www" }, includeFilters = {
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Controller.class) })
public class WebMvcConfig implements WebMvcConfigurer {

@Autowired
Environment env;

/**
* Servlet Filters
*/
Expand Down Expand Up @@ -117,7 +116,10 @@ public SpringResourceTemplateResolver springResourceTemplateResolver() {
srtr.setPrefix("classpath:templates/");
srtr.setSuffix(".html");
srtr.setTemplateMode(TemplateMode.HTML);
srtr.setCacheable(false);

if (env.getActiveProfiles().length == 0 || !"prod".equals(env.getActiveProfiles()[0])) {
srtr.setCacheable(false);
}
return srtr;
}
@Bean
Expand All @@ -135,6 +137,18 @@ public ThymeleafViewResolver thymeleafViewResolver() {
return tvr;
}

/*
@Override
public void configureContentNegotiation (ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(true).
ignoreAcceptHeader(true).
useJaf(false).
defaultContentType(MediaType.APPLICATION_JSON).
mediaType("json", MediaType.APPLICATION_JSON).
mediaType("view", MediaType.TEXT_HTML).
mediaType("xlsx", MediaType.valueOf("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
}
*/
@Override
public void configureContentNegotiation (ContentNegotiationConfigurer configurer) {
Map<String, MediaType> mediaTypes = new HashMap<String, MediaType>();
Expand Down Expand Up @@ -174,11 +188,11 @@ public ExceptionResolver exceptionResolver() {
}

@Bean
public CommonsMultipartResolver multipartResolver() {
CommonsMultipartResolver cmr = new CommonsMultipartResolver();
cmr.setMaxUploadSize(52428800); // 50MB
cmr.setMaxInMemorySize(52428800); // 50MB
return cmr;
public MultipartResolver multipartResolver() {
// CommonsServletMultipartResolver cmr = new CommonsServletMultipartResolver();
// cmr.setMaxUploadSize(52428800); // 50MB
// cmr.setMaxInMemorySize(52428800); // 50MB
return new StandardServletMultipartResolver();
}

@Bean
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/common/exception/ExceptionResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import java.util.Locale;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.mybatis.spring.MyBatisSystemException;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/common/filter/XSSFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;

/**
* @author KIM HWANG MAN( bbalganjjm@gmail.com )
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/common/filter/XSSFilterRequestWrapper.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package common.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;

import common.utils.SecurityUtils;

Expand Down
15 changes: 6 additions & 9 deletions src/main/java/common/interceptor/PermissionCheckInterceptor.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package common.interceptor;

import java.lang.invoke.MethodHandles;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.lang.invoke.MethodHandles;

/**
* @author KIM HWANG MAN( bbalganjjm@gmail.com )
* @since 2018.12.05
*/
public class PermissionCheckInterceptor extends HandlerInterceptorAdapter {
public class PermissionCheckInterceptor implements HandlerInterceptor {
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

public String[] excludeURLs;
Expand Down Expand Up @@ -48,11 +47,9 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons

public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
throws Exception {
super.postHandle(request, response, handler, modelAndView);
}

public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
super.afterCompletion(request, response, handler, ex);
}

}
4 changes: 2 additions & 2 deletions src/main/java/common/mybatis/MaskingInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.Map;
import java.util.Properties;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.cache.CacheKey;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/common/mybatis/MaxRowsLimitInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;
import java.util.Properties;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import org.apache.ibatis.executor.resultset.ResultSetHandler;
import org.apache.ibatis.plugin.Interceptor;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/common/mybatis/XlsxStreamingInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import java.util.Objects;
import java.util.Properties;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.executor.Executor;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/common/views/FileView.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.net.URLEncoder;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.springframework.util.FileCopyUtils;
import org.springframework.web.servlet.view.AbstractView;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/common/views/XlsxStreamingView.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import java.util.Map;
import java.util.Objects;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.commons.io.FileUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
Expand Down
Loading

0 comments on commit f668600

Please sign in to comment.