IT/spring
-
spring boot 세션만료 감지IT/spring 2021. 4. 22. 16:41
spring boot 세션 만료 감지 @Slf4j @Component public class SessionSestoryListener implements ApplicationListener { @Autowired ActionHistoryRepository actionHistoryRepository; @Override public void onApplicationEvent(SessionDestroyedEvent event) { List securityContexts = event.getSecurityContexts(); log.debug("--->{}, {}", event, securityContexts); for (SecurityContext sc: securityContexts) { log.debug(..
-
spring data jpa @Entity schema, catalog properties처리하기.IT/spring 2021. 3. 24. 16:49
spring data jpa @Entity schema, catalog properties처리하기. @Component @Slf4j public class HibernateInterceptor extends EmptyInterceptor { private static Environment env; public HibernateInterceptor() { } @Autowired public HibernateInterceptor(Environment env) { this.env = env; } @Override public String onPrepareStatement(String sql) { if (null != env) { String regEx = "\\$\\{([\\\\.\\w_-]+)\\}"; Pa..
-
spring boot 로컬에서 smtp mail 테스트하기IT/spring 2021. 2. 18. 11:11
로컬에서 smtp mail 테스트 하는 방법 입니다. maildev docker 준비 docker run -p 80:80 -p 25:25 maildev/maildev dependencies { ... implementation 'org.springframework.boot:spring-boot-starter-mail' } test { ... String activeProfile = System.properties['spring.profiles.active'] println "zone: $activeProfile" systemProperty "spring.profiles.active", activeProfile } build.gradle @Slf4j @Configuration public class Cor..
-
spring 시작(startup)과 끝 (end) 이벤트 받아오기IT/spring 2021. 2. 8. 16:27
@Slf4j @SpringBootApplication public class CellApplication { ... public static void main(String[] args) throws IOException { SpringApplicationBuilder builder = new SpringApplicationBuilder(CellApplication.class); builder.web(WebApplicationType.NONE).build().addListeners(new ApplicationPidFileWriter()); builder.run(args); } @EventListener public void applicationStartedEvent(ApplicationStartedEven..
-
-
spring method argumentResolvers (controller 파라미터 맵핑)IT/spring 2021. 2. 8. 16:10
@Configuration @EnableWebMvc @EnableConfigurationProperties(ProjectProperties.class) @EnableScheduling @EnableTransactionManagement public class ApiWebMvcConfigurerAdapter implements WebMvcConfigurer { ... @Override public void addArgumentResolvers(List argumentResolvers) { argumentResolvers.add(new HandlerMethodArgumentResolver() { @Override public boolean supportsParameter(MethodParameter para..
-
spring 다국어처리 2가지 session, Accept-LanguageIT/spring 2021. 2. 8. 16:02
session @Configuration @EnableConfigurationProperties(ProjectProperties.class) public class CmsWebMvcConfigurerAdapter implements WebMvcConfigurer { ... @Bean public LocaleResolver localeResolver() { SessionLocaleResolver slr = new SessionLocaleResolver(); slr.setDefaultLocale(Locale.US); return slr; } public LocaleChangeInterceptor localeChangeInterceptor() { LocaleChangeInterceptor lci = new L..