Category Archives: FrameWork

[spring] WebMvcConfigurer > addInterceptors > excludePathPatterns 의 wildcard(*, asterisk) 문법에 대하여 (url 패턴에 의한 권한체크 필터)

By | 4월 27, 2023

예시 // 작동함 .excludePathPatterns("/aaa/**") .excludePathPatterns("/bbb*/**") // 작동하지 않음 .excludePathPatterns("/aaa**") // 별표 두개는 꼭 슬래쉬 뒤에 와야 하는 것 같다. 순서에 대하여 gpt에 물어보니, 패턴을 정의하는 순서에 의미가 있다고 한다. (위의 것이 먼저 필터링) 실험 결과 넓은 url 범위를 exclude 하고, 하위의 좁은 범위를 다시 add 했을 때, add가 의도한대록 작동(권한체크)되지는 않았다. (gpt는 된다고 했는데…?)

spring web 에서 파라미터를 전송할 때, 아무 이유 없이 파라미터 바인딩(parameter, bind, bound)이 되지 않았던 경우 (camel case, jackson)

By | 12월 13, 2022

전달되지 않은 파라미터 명: fInput 전달된 파라미터 명: ffInput ??? 원인 jackson이 java bean naming convention을 사용하는데, java 표준에는 ‘Don’t capitalize first two letters of a bean property name’ 라는 룰이 있다고 한다. 결국 jackson이 json parsing 하는 각 프로퍼티의 첫 두 글자는 무조건 소문자여야 한다는 것. 참고 https://stackoverflow.com/questions/30205006/why-does-jackson-2-not-recognize-the-first-capital-letter-if-the-leading-camel-c http://futuretask.blogspot.com/2005/01/java-tip-6-dont-capitalize-first-two.html

[링크] mybatis 에서 package 단위의 typealias를 정의할 때 wildcard (*) 사용하기

By | 7월 15, 2022

요약 아래의 형태 가능 (since mybatis-spring 2.0.1) mybatis.type-aliases-package=com.example.**.model mybatis.type-handlers-package=com.example.*.typehandler mybatis-config.xml 에서는 지원하지 않음 그냥 mybatis 가 아니라 mybatis-spring에서 지원하는 기능이기 때문 원글 https://github.com/mybatis/spring-boot-starter/issues/314

[펌글] SpringDoc (swagger 생성기) 을 노출하지 않기 (운영환경에서 필요할 듯)

By | 7월 4, 2022

Hi, This feature will be added on v1.2.12, of springdoc-openapi. This property helps you disable only the ui. springdoc.swagger-ui.enabled=false The following property, will help you disable the api-docs Rest endpoints as well: springdoc.api-docs.enabled=false 출처 https://github.com/springdoc/springdoc-openapi/issues/191

[링크] [java/spring] 쿼리 로그 출력시 파라미터 값이 바인딩된 채로 출력되게 하는 방법 (parameter bound query sql log) – log4jdbc-log4j2

By | 6월 23, 2022

https://rimkongs.tistory.com/312 이게 2013년 이후 업데이트가 끊긴 라이브러리라 최근에는 사용할 수 없을 거라고 막연히 생각했었는데, 웬걸, 2022년 지금도 잘 돌아가고 있는 모양이다. 괜히 p6spy 쓴다고 낑낑댄 건 아닌지 모르겠다. 심지어 이넘은 쿼리 결과도 테이블 모양으로 이쁘게 찍어준다.

spring boot jar 실행시 mybatis typeAlias 관련 오류 해결 (SpringBootVFS)

By | 4월 13, 2022

환경 springboot 2.6.3 mybatis-spring-boot-starter 2.2.2 mybatis 설정파일에 typeAlias 를 정의해 사용하고 있음. 서버 기동(springboot jar 파일 실행)시 에러메시지 org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘[VO클래스명]’. Cause: java.lang.ClassNotFoundException: Cannot find class: [VO클래스명] 이 에러는 spring boot를 jar로 packaging하여 실행하는 경우에만 발생한다고 함. 해결 (xml config) 나는 설정의 편의를 위해 java config가… Read More »

org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory 오류 해결

By | 12월 10, 2021

환경 spring boot 1.5.22 (spring 4.3.25) JEUS 7 Fix#5 개요 잘 돌던 시스템이, apache poi를 pom에 추가한 시점부터 JEUS 서버 기동시 오류를 내뿜었다. (주로 logback.xml 을 읽지 못했다… 라는 내용의 로그였음) 해결 pom.xml > dependency > poi-ooxml 에 아래와 같이 exclusion 처리 추가 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.9</version> <exclusions> <exclusion> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> </exclusion> </exclusions> </dependency> 출처… Read More »

[ibatis/oracle] 내장 반복문을 통해 대량(배치, batch) insert 를 하는 샘플

By | 10월 21, 2021

Mybatis 아니고, 골동품인 Ibatis 입니다. 생각지도 못한 에러들이 나와서 (ora-00933 등..) 삽질을 했네요. (시간 아깝 ㅠ.ㅡ) <insert id="BatchDAO.insertMemberRest" parameterClass="java.util.HashMap"> INSERT ALL /* BatchDAO.insertMemberRest */ <iterate property="mberList" conjunction=" "> INTO COMTNGNRLMBERREST ( MBER_ID, PASSWORD ) VALUES ( #mberList[].MBER_ID#, #mberList[].PASSWORD# ) </iterate> SELECT * FROM DUAL </insert> 그런데 하다 보니 이것도 조심해야 할 것 같다는 생각이 들었다.… Read More »

springboot 환경설정 메모 (ver 1.5.22)

By | 9월 23, 2021

web환경 (servlet..)을 제거하는 설정 application.yml spring: main: web-environment: false spring security 를 제거하는 설정 기동 클래스 @SpringBootApplication(exclude = { SecurityAutoConfiguration.class }) application.yml security: basic: enabled: false management: security: enabled: false

Mybatis 오라클 프로시저 (Oracle Stored Procedure) 호출시, ‘java.sql.SQLException: 해당 위치에 지원되지 않는 SQL92 토큰: 1:’ 오류 발생 케이스.

By | 8월 20, 2021

이 케이스는 그야말로 황당 그 자체! 결론부터 말하면 mybatis xml 에서, 중괄호와 소괄호를 다른 라인에 위치시켜서 발생 한 문제이다. 그것도 같은 프레임워크에서 돌리는 MariaDB 프로시저 호출시는 문제가 없는데, ‘오라클 프로시저 호출시에만’ 이 문제가 발생했다. 전혀 예상 못하고 헤멜뻔 했는데, 인터넷에 또 선구자가 계셔서 해결할 수 있었다. 잘못된 예 { CALL PKG_A.PROC_TEST( #{rsltcode, mode=OUT, jdbcType=VARCHAR}, #{rsltmsg,… Read More »

Spring @Scheduled 스케쥴러 사용 샘플 (cron 표현식 등)

By | 8월 11, 2021

Spring Boot 라면 @EnableScheduling 을 붙여서 기본 셋팅이 가능한 것 같은데, 일반 Spring 에서는 아래와 같은 셋팅을 추가해 주어야 한다. thread pooling 관련 설정을 하기도 하는 것 같은데, 여기서는 가장 심플한 구성을 사용하기로 한다. spring context xml (‘task’ 가 포인트) <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!–… Read More »

json 출력 혹은 swagger 문서에서 VO객체의 일부 필드(멤버) 숨기기 (Spring 4, jackson2, springfox 2.9 환경)

By | 6월 30, 2021

@ApiModelProperty(notes = "책 썸네일 atchFileId", hidden = true) @JsonIgnore private String bookThumbnailFileId; swagger의 모델 정의에서 필드 숨기기 @ApiModelProperty를 아예 필드에 붙이지 않는다. 모종의 이유로 붙였을 경우에는 @ApiModelProperty(hidden = true)를 사용한다. json response 에서 필드 숨기기 @JsonIgnore 를 사용한다. @JsonIgnore는 꼭 com.fasterxml.jackson.annotation.JsonIgnore 을 사용해야 한다. (java 패키지 확인)

MyBatis insert 문 사용시 PK 획득하기 (useGeneratedKeys)

By | 9월 25, 2021

mybatis query xml <insert id="insertBook" useGeneratedKeys="true" keyProperty="bookId"> INSERT /* insertBook */ INTO book ( book_title ) VALUES ( #{bookTitle} ) </insert> 쿼리 이후 result 객체가 아닌 parameter 객체에서 bookId 를 참조하면 PK 획득. 이 테이블의 PK는 book_id 이지만 auto increment 이기 때문에 쿼리에는 기재되지 않았음. 대신 keyProperty 에 프로퍼티명이 명시되어 있음 mybatis config에 mapUnderscoreToCamelCase 가… Read More »

[펌글] Spring Security 에서의 CORS 설정

By | 6월 29, 2021

spring security config 클래스 @EnableWebSecurity public class CustomSecurityConfig extends WebSecurityConfigurerAdapter { … @Override protected void configure(HttpSecurity http) throws Exception { http … .and() .authorizeRequests() .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() // cors setting 1 … .and().cors(); // cors setting 2 } // cors setting 3 @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); // configuration.addAllowedOrigin("*"); configuration.addAllowedOrigin("http://localhost:3000"); configuration.addAllowedMethod("*"); configuration.addAllowedHeader("*");… Read More »

Mybatis 오류 어리둥절 케이스 (Error setting non null for parameter #12 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Could not set parameter at position 12 (values was ‘1’))

By | 6월 23, 2021

이 오류의 해결을 위해서 한참을 헤멨는데, mybatis mapper config 의 jdbcTypeForNull 을 NULL로 해 주라느니 등등 이것저것 해 봤지만 아무리 해도 듣지 않았다. 변수 바인딩 표현식 #{}도 오타/누락 등의 문제 없었고, 파라미터 갯수도 문제 없고. 그러다가 그냥 기존 xml 쿼리를 밀고 다시 짰더니 됐다. -_-… 뭐지..뭐였지…