diff --git a/pom.xml b/pom.xml index dda8c24..df962e1 100644 --- a/pom.xml +++ b/pom.xml @@ -15,14 +15,14 @@ org.springframework.boot spring-boot-starter-parent - 2.3.5.RELEASE + 3.1.2 UTF-8 UTF-8 - 1.8 + 17 @@ -50,7 +50,7 @@ org.mybatis.spring.boot mybatis-spring-boot-starter - 2.1.4 + 3.0.2 org.springframework.boot @@ -90,7 +90,7 @@ commons-fileupload commons-fileupload - 1.4 + 1.5 @@ -114,13 +114,20 @@ org.apache.poi poi-ooxml - 4.1.2 + 5.2.3 org.springframework.boot spring-boot-devtools - + + + javax.annotation + javax.annotation-api + 1.3.2 + + + install diff --git a/src/main/java/common/app/file/XlsxToJSONController.java b/src/main/java/common/app/file/XlsxToJSONController.java index e97efce..d32e7ab 100644 --- a/src/main/java/common/app/file/XlsxToJSONController.java +++ b/src/main/java/common/app/file/XlsxToJSONController.java @@ -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; diff --git a/src/main/java/common/aspects/VOFilterAspect.java b/src/main/java/common/aspects/VOFilterAspect.java index eb2b9fd..98ac827 100644 --- a/src/main/java/common/aspects/VOFilterAspect.java +++ b/src/main/java/common/aspects/VOFilterAspect.java @@ -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; diff --git a/src/main/java/common/config/WebMvcConfig.java b/src/main/java/common/config/WebMvcConfig.java index 9992d60..61708c9 100644 --- a/src/main/java/common/config/WebMvcConfig.java +++ b/src/main/java/common/config/WebMvcConfig.java @@ -4,13 +4,12 @@ * @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; @@ -18,13 +17,14 @@ 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; @@ -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 */ @@ -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 @@ -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 mediaTypes = new HashMap(); @@ -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 diff --git a/src/main/java/common/exception/ExceptionResolver.java b/src/main/java/common/exception/ExceptionResolver.java index 595f767..5dbc7ab 100644 --- a/src/main/java/common/exception/ExceptionResolver.java +++ b/src/main/java/common/exception/ExceptionResolver.java @@ -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; diff --git a/src/main/java/common/filter/XSSFilter.java b/src/main/java/common/filter/XSSFilter.java index 725511e..dfeb6f9 100644 --- a/src/main/java/common/filter/XSSFilter.java +++ b/src/main/java/common/filter/XSSFilter.java @@ -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 ) diff --git a/src/main/java/common/filter/XSSFilterRequestWrapper.java b/src/main/java/common/filter/XSSFilterRequestWrapper.java index 02015f3..4399652 100644 --- a/src/main/java/common/filter/XSSFilterRequestWrapper.java +++ b/src/main/java/common/filter/XSSFilterRequestWrapper.java @@ -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; diff --git a/src/main/java/common/interceptor/PermissionCheckInterceptor.java b/src/main/java/common/interceptor/PermissionCheckInterceptor.java index a8e309d..c766676 100644 --- a/src/main/java/common/interceptor/PermissionCheckInterceptor.java +++ b/src/main/java/common/interceptor/PermissionCheckInterceptor.java @@ -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; @@ -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); } } \ No newline at end of file diff --git a/src/main/java/common/mybatis/MaskingInterceptor.java b/src/main/java/common/mybatis/MaskingInterceptor.java index 3ae924b..2b4595d 100644 --- a/src/main/java/common/mybatis/MaskingInterceptor.java +++ b/src/main/java/common/mybatis/MaskingInterceptor.java @@ -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; diff --git a/src/main/java/common/mybatis/MaxRowsLimitInterceptor.java b/src/main/java/common/mybatis/MaxRowsLimitInterceptor.java index 2642635..7f1609c 100644 --- a/src/main/java/common/mybatis/MaxRowsLimitInterceptor.java +++ b/src/main/java/common/mybatis/MaxRowsLimitInterceptor.java @@ -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; diff --git a/src/main/java/common/mybatis/XlsxStreamingInterceptor.java b/src/main/java/common/mybatis/XlsxStreamingInterceptor.java index b9c3cf4..27b4c22 100644 --- a/src/main/java/common/mybatis/XlsxStreamingInterceptor.java +++ b/src/main/java/common/mybatis/XlsxStreamingInterceptor.java @@ -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; diff --git a/src/main/java/common/views/FileView.java b/src/main/java/common/views/FileView.java index 37e438b..4f73945 100644 --- a/src/main/java/common/views/FileView.java +++ b/src/main/java/common/views/FileView.java @@ -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; diff --git a/src/main/java/common/views/XlsxStreamingView.java b/src/main/java/common/views/XlsxStreamingView.java index 4e3f361..d539e7b 100644 --- a/src/main/java/common/views/XlsxStreamingView.java +++ b/src/main/java/common/views/XlsxStreamingView.java @@ -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; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 40eb9da..32a4de5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,12 +1,16 @@ spring: profiles: active: default + sql: + init: + platform: hsqldb + schema-locations: + - classpath*:config/db/hsqldb/schema.sql + data-locations: + - classpath*:config/db/hsqldb/data.sql + encoding: UTF-8 datasource: - #name: ds-common - platform: hsqldb - schema: classpath*:config/db/hsqldb/schema.sql - data: classpath*:config/db/hsqldb/data.sql - sqlScriptEncoding: UTF-8 + # name: ds-common driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy url: jdbc:log4jdbc:hsqldb:mem:dataSource;sql.syntax_ora=true username: sa @@ -91,66 +95,66 @@ management: ---- -spring: - profiles: prod - datasource: - #name: ds-common - platform: hsqldb - schema: classpath*:config/db/hsqldb/schema.sql - data: classpath*:config/db/hsqldb/data.sql - sqlScriptEncoding: UTF-8 - driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:hsqldb:mem:dataSource - username: sa - password: '' - tomcat: - initialSize: 20 - maxActive: 80 - maxIdle: 80 - testWhileIdle: true - timeBetweenEvictionRunsMillis: 60000 - validationQuery: select 1 from INFORMATION_SCHEMA.SYSTEM_USERS - test-on-borrow: true - messages: - basename: messages/message-common - encoding: UTF-8 - use-code-as-default-message: true - cache-duration: -1 - mvc: - servlet: - path: / - -server: - port: 8080 - servlet: - contextPath: / - encoding: - charset: UTF-8 - enabled: true - force: true - error: - include-exception: true - include-stacktrace: always - -mybatis: - configuration: - default-statement-timeout: 30 - cache-enabled: true - lazy-loading-enabled: true - default-fetch-size: 50 - multiple-result-sets-enabled: true - use-column-label: true - use-generated-keys: false - auto-mapping-behavior: partial - default-executor-type: simple - safe-row-bounds-enabled: false - map-underscore-to-camel-case: true - local-cache-scope: session - jdbc-type-for-null: null - lazy-load-trigger-methods: equals,clone,hashCode,toString - mapper-locations: - - classpath*:/**/mappers/**/*.xml -logging: - level: - root: warn +#--- +#spring: +# profiles: prod +# datasource: +# #name: ds-common +# platform: hsqldb +# schema: classpath*:config/db/hsqldb/schema.sql +# data: classpath*:config/db/hsqldb/data.sql +# sqlScriptEncoding: UTF-8 +# driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy +# url: jdbc:log4jdbc:hsqldb:mem:dataSource +# username: sa +# password: '' +# tomcat: +# initialSize: 20 +# maxActive: 80 +# maxIdle: 80 +# testWhileIdle: true +# timeBetweenEvictionRunsMillis: 60000 +# validationQuery: select 1 from INFORMATION_SCHEMA.SYSTEM_USERS +# test-on-borrow: true +# messages: +# basename: messages/message-common +# encoding: UTF-8 +# use-code-as-default-message: true +# cache-duration: -1 +# mvc: +# servlet: +# path: / +# +#server: +# port: 8080 +# servlet: +# contextPath: / +# encoding: +# charset: UTF-8 +# enabled: true +# force: true +# error: +# include-exception: true +# include-stacktrace: always +# +#mybatis: +# configuration: +# default-statement-timeout: 30 +# cache-enabled: true +# lazy-loading-enabled: true +# default-fetch-size: 50 +# multiple-result-sets-enabled: true +# use-column-label: true +# use-generated-keys: false +# auto-mapping-behavior: partial +# default-executor-type: simple +# safe-row-bounds-enabled: false +# map-underscore-to-camel-case: true +# local-cache-scope: session +# jdbc-type-for-null: null +# lazy-load-trigger-methods: equals,clone,hashCode,toString +# mapper-locations: +# - classpath*:/**/mappers/**/*.xml +#logging: +# level: +# root: warn