개인적으로 문제가 해결된 방안을 공유하고자 하는 것이며

반드시 해결되지 않을 수 있음을 알려드립니다.

 

DB에서 쿼리 결과를 받아오는 경우 java콘솔쪽에선 카멜/언더스코어 변경 필요한 컬럼의 값이 전부 default 값으로 받아짐.

 

해당 쿼리를 MySQL에서 직접 실행 시 문제 없음.

 

1   ) application.yml에 "mybatis: configuration: map-underscore-to-camel-case: true" 잘 적혀있음. 경고나 에러 표시 없음.

 

1-1 ) DBConfiguration.java에 @PropertySource("classpath:/application.yml")로 잘 적혀있나?(기본 경로임)

  - 잘 작성돼있음.

결론 : 작동 안함...(이유 아직 모름)

 

 

 

2) ~~Mapper.xml에 resultMap 작성하고 쿼리 구문쪽에 resultMap="~~" 추가 시 값 정상적으로 들어옴.....

결론 : 작동함. 하지만 프로젝트마다 하드코딩이기 때문에 사용하지않는 것 추천

 

 

 

3-1 ) maybatis-config.xml 파일 생성 후 아래와 같이 작성

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 
	"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
	<settings>
		<setting name="mapUnderscoreToCamelCase" value="true"/>
	</settings>
</configuration>

3-2 ) DBConfiguration.java의 SqlSessionFactoryBean 설정 부분에 아래 문장 추가

classpath는 설정 파일 경로마다 바뀔 수 있음.

factoryBean.setConfigLocation(applicationContext.getResource("classpath:mybatis-config.xml"));

결론 : 정상 작동함. ~~Mapper.xml에서 resultMap 설정 할 필요없음. 

 

 

1번이 되지않는 관계로... 3번 방식으로 진행함.

 개인적으로 문제가 해결된 방안을 공유하고자 하는 것이며

반드시 해결되지 않을 수 있음을 알려드립니다.

 

DBConfiguration.class에서 

 

매퍼 xml 등록을 위해

factoryBean.setMapperLocations(applicationContext.getResources("classpath:mappers/**/*Mapper.xml"));

추가시 하기 에러 발생

 

- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [경로/클래스명.class]

 

- Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource:

 

등등의 오류 메세지 길게 나옴

 

mapper.xml에 포함된 parametrType, resultType 등의 클래스명 앞에 경로 추가 후 하기 메세지 발생

 

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.ibatis.reflection.Reflector (file:/C:/Users/baang/.m2/repository/org/mybatis/mybatis/3.4.1/mybatis-3.4.1.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.apache.ibatis.reflection.Reflector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

 

pom.xml에서 mybatis 버전 업데이트 후 에러 사라짐.

 개인적으로 문제가 해결된 방안을 공유하고자 하는 것이며

반드시 해결되지 않을 수 있음을 알려드립니다.

 

spring security에 의해 토큰 필요

 

<head>내에 아래 삽입

<meta name="_csrf" th:content="${_csrf.token}">
<meta name="_csrf_header" th:content="${_csrf.headerName}">

 

<script>내에 아래 선언 후 헤더에 넣기

let header = $("meta[name='_csrf_header']").attr('content');
let token = $("meta[name='_csrf']").attr('content');

+ Recent posts