[Spring] Spring Security Session Timeout Disable.
ITWeb/개발일반 2020. 7. 23. 07:55application.yml 또는 properties 파일 내 아래와 같이 선언 하시면 됩니다.
server:
servlet:
session:
timeout: 0
'ITWeb/개발일반'에 해당되는 글 490건
[Spring] Spring Security Session Timeout Disable.ITWeb/개발일반 2020. 7. 23. 07:55application.yml 또는 properties 파일 내 아래와 같이 선언 하시면 됩니다.
[Java] jar 파일 내 resources 읽기 - ClassPathResourceITWeb/개발일반 2020. 7. 21. 20:23제목에 있는 그대로 입니다.
[참고문서]
ClassPathResource 를 이용해서 구현 하면 됩니다.
아래 예제 코드는 programcreek.com 에서 가져 왔습니다.
이와 같이 구현을 한 이유는 로컬에서는 잘 되는데 jar 로 말았을 때는 file 을 찾지 못하는 에러가 발생을 해서 입니다. [Spring] viewResolver return types...ITWeb/개발일반 2020. 7. 21. 10:45[참고문서] https://docs.spring.io/spring/docs/3.0.0.M3/spring-framework-reference/html/ch16s03.html
Spring mvc framework 에서 Controller 에서 사용하는 return type 에 따른 viewResolver 적용방법이 다릅니다. 위 문서를 보시면 이해 하실 수 있습니다.
가장 많이 사용 하는 몇 개만 뽑아 왔습니다.
제가 실수한 부분은 void 로 선언을 해 놓고 template 수정 후 반영이 되지 않아 cache 를 의심 했었는데 역시 원인은 제가 선언을 잘 못 했기 때문 이였습니다.
void 로 선언 시 해석은
hello.html 을 template 으로 찾게 됩니다.
[Terraform] apply 후 생성 된 정보 구하기.ITWeb/개발일반 2020. 7. 21. 08:44Terraform 을 이용해서 인프라 구성을 한 후에 생성된 정보를 얻어 와야 할 때가 있습니다. 특정 정보만 구하고 싶을 경우 output 설정을 이용해서 얻을 수 있는 방법과 state 를 이용해서 얻을 수 있는 방법이 있습니다.
[참고문서] https://www.terraform.io/docs/commands/output.html
tf 설정 파일 내 output 설정을 합니다.
아래와 같이 하면 모든 state 정보를 return 해 줍니다.
[Spring] Spring Security 기본 Login Form 제거 및 CSRF 만 사용하기ITWeb/개발일반 2020. 7. 7. 08:33사용하다 보면 별의 별 요구사항이 나오게 됩니다. 단순 하게 CSRF 만 사용 하고 싶은데 자꾸 login form 이 나와서 설정만으로 이걸 해결해 보고자 했습니다. 그러나 설정 만으로는 안되더라고요.
설정 예시) 비추천
코드 예시) 추천
참고 정보)
[Spring] 다국어(i18n) 적용 하기.ITWeb/개발일반 2020. 7. 6. 16:08다국어를 적용 하기 위한 Code Snippet
1. Javascript - 구글링 해보시면 몇 가지 framework 들이 나옵니다. - 쉽게 구현을 한다고 하면, 현재의 locale 정보를 cookie 또는 session 에서 읽어 와서 해당 하는 locale 의 message 파일 또는 변수를 가지고 설정 하면 됩니다.
예제)
- 여기서 원래는 jquery 를 이용 하다 보니 $ 가 들어 갔었는데 $(document).ready(); 였으나 $를 찾지 못해서 걍 바꿔 놓았습니다. - 코드 설명은 쉽습니다. 그냥 정적으로 정의해서 사용 하는 내용이라 보시면 다 아실 것 같습니다.
2. Spring Boot + Thymeleaf Cookie 와 Session 두 가지로 적용이 가능 합니다. 구글링 해보시면 거의 똑같은 코드로 예제들이 나올 거예요. 그냥 담는 그릇을 Cookie 로 할건지 Session 으로 할 건지의 차이 라고 보시면 됩니다. - 프로젝트에서 "Resource Bundle 'messages'" 를 추가해 주세요. - 추가 하면서, ko, en, ja, zh 생성 하시면 됩니다. - messages.properties - messages_ko.properties HELLO=안녕 - messages_en.properties HELLO=Hello - messages_zh.properties - messages_ja.properties HELLO=こんにちは
2.1 Session
2.2 Cookie
그래서 Thymeleaf 에서는 아래와 같이 쓰시면 됩니다.
[Spring] Spring Cloud Config 설정 파일 적용ITWeb/개발일반 2020. 6. 25. 14:29spring config client 에 server config 파일이 존재 할 경우 적용 안되는 문제를 해결 하기 위해 아래 설정을 하면 됩니다.
1.4. Overriding the Values of Remote PropertiesThe property sources that are added to your application by the bootstrap context are often “remote” (from example, from Spring Cloud Config Server). By default, they cannot be overridden locally. If you want to let your applications override the remote properties with their own system properties or config files, the remote property source has to grant it permission by setting spring.cloud.config.allowOverride=true (it does not work to set this locally). Once that flag is set, two finer-grained settings control the location of the remote properties in relation to system properties and the application’s local configuration:
[Spring] Spring boot tomcat relaxedQueryCharsITWeb/개발일반 2020. 6. 25. 11:35Common Application properties Various properties can be specified inside your application.properties file, inside your application.yml file, or as command line switches. This appendix provides a list of common Spring Boot properties and references to the underlying classes that consume docs.spring.io https://tomcat.apache.org/tomcat-9.0-doc/config/http.html Apache Tomcat 9 Configuration Reference (9.0.36) - The HTTP Connector This Connector supports all of the required features of the HTTP/1.1 protocol, as described in RFCs 7230-7235, including persistent connections, pipelining, expectations and chunked encoding. If the client supports only HTTP/1.0 or HTTP/0.9, the Connector tomcat.apache.org
의도치 않게 tomcat 에서 에러 처리를 해버려서 이를 방지 하기 위해 설정 후 application 에서 처리 하시면 됩니다. [Spring] Spring Cloud Config 다중 Backend 사용 시...ITWeb/개발일반 2020. 6. 18. 10:41Spring Cloud Config 를 이용해서 다중 Backend 를 구성 할 수 있습니다. 그러나 order 옵션이 저는 제대로 동작 하지 않아서 실행 시 사용해야 하는 Backend 에 대한 profile 로 관리하기로 했습니다.
동시에 두 개의 Backend 를 사용 하는 것도 가능 한데 이게 같은 설정 파일이 양쪽에 다 존재 할 때 order 에 맞춰서 설정 정보를 가져 와야 하는데 이상하게도 git 에 있는 설정을 먼저 가져 와서 목적에 맞게 사용을 할 수 없었습니다.
저렇게 설정 하고 했었는데 잘 못된 부분이 있다면 댓글 좀 달아 주세요. :)
profile을 실행 시점에 awss3 나 git 으로 설정해서 사용 하도록 마무리 했습니다. [Spring] @RefreshScope 적용 시 반영이 잘 안될 때ITWeb/개발일반 2020. 6. 16. 14:51일단 spring config server 에서 설정을 변경해서 적용 합니다.
POST , /actuator/refresh 를 실행 합니다.
그럼 기대 하는 건 변경 된 설정 값이 반영이 되어 있어야 한다는 것입니다.
그러나 반영이 안되어 있어서 디버깅 하다 아래와 같이 event 를 잡아서 처리를 해주니 잘되는 것을 확인 했습니다.
참고해서 보셔야 하는 코드는 아래 입니다.
refreshAll() 을 호출 하게 되어서 반영이 잘됩니다.
더불어 그냥 프레임워크에서 제공하는 @Scheduled 사용 하십시오.
|