728x90
반응형
728x90
반응형
728x90
반응형

VO의 파라미터 변경하여 사용하고 싶어서 @JsonProperty를 사용하려고 gradle에 2.9.8 버전을 추가했는데 org.springframework.beans.factory.BeanCreationException 에러가 났다.

 

검색해 본 결과(링크) 2.10.0 버전 사용을 추천해 줬고 그래서 해결 했다.

1
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.10.0'
cs

 

# 아래는 에러 메시지

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

20210429 21:07:13.377 [main] ERROR o.s.b.SpringApplication - Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectMapper' defined in class path resource [packageName/WebMvcConfig.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.fasterxml.jackson.databind.ObjectMapper] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:582)

at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)

at packgeNameApplication.main(Application.java:10)

Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.fasterxml.jackson.databind.ObjectMapper] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)

at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)

at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:417)

at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:388)

at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:335)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1098)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)

... 16 common frames omitted

Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/StreamReadFeature

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Unknown Source)

at java.lang.Class.getDeclaredMethods(Unknown Source)

at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)

... 22 common frames omitted

Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.StreamReadFeature

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

... 26 common frames omitted

 

 

 

728x90
반응형
728x90
반응형

테이블을 그리는 것과는 별개로 pagination을 그리고 싶었다.

 

내가 적용한 실 사용 예제은 아래와 같다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// simple pagenation 세팅
$('#light-pagination').pagination({
    pages: 20// 전체 페이지 수 (total pagination count)
    cssStyle: 'light-theme',
    useAnchors : false,
    displayedPages : 5
        // pages가 이것보다 큰 경우 한번에 연속된 페이지 번호를 몇개를 보여줄지, 기본이 5
    edges : 1
        // displayedPages 갯수를 넘어서는 경우 시작/끝 페이지 번호를 몇개를 표시할지
        // (visible at the beginning/ending of the pagination)
    currentPage : 1// 시작시 선택할 페이지 번호
    onPageClick : function(pageNumber, event) {
        // 페이지 번호 클릭시 이벤트
        // pageNumber : 클릭한 페이지 번호
    },        
});
 
// 검색으로 페이지수가 줄었을 경우 사용할만한 API
$('#light-pagination').pagination('setPagesCount'15); // pages를 변경
$('#light-pagination').pagination('selectPage'2); // currentPage를 변경
$('#light-pagination').pagination('redraw'); // 다시 그리기, setPagesCount 사용시 필요
cs

 

 

 

 

자세한정보는 여기 참조.

 

728x90
반응형
728x90
반응형

mybatis로 조회된 쿼리문의 결과에서 unread로 컬럼정보가 표시되는 경우가 있었다.

 

 

1. mybatis의 쿼리 내용

1
2
3
4
5
6
7
8
<mapper namespace="com.sample.mapper.memberMapper">
    <!-- unread 발생 -->
    <select id="read" resultType="com.sample.mapper.MemberVO">
        SELECT SEQ, NAME, SEX, EMAIL_ADDR, PASSWORD, BIRTH, ADDR, THUMB, PROFILE 
       FROM MEMBER WHERE SEQ = #{seq}
    </select>
</mapper>
 
cs

 

2. resultType의 MemberVO 내용

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class MemberVO {
    
    private int seq;
    private String name;
    private int sex;
    private String email;
    private String passWord;
    private String birth;
    private String add;
    private String thumb;
    private String profile;
    private int is_delete;
 
}
cs

3. DB 테이블 정보

 

 

문제는 원인은 MemberVO클래스의 변수와 DB 컬럼명이 다르다.

그러니 누가 누구와 연결되는지 명확하지가 않다. (대소문자는 구분하지 않음)

그래서 클래스 변수와 DB의 컬럼명을 맵핑하여 이 문제를 해결한다.

 

4. 1번의 mybatis에서 컬럼명과 변수를 맵핑하는 정보를 추가

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<mapper namespace="com.sample.mapper.memberMapper">
    <!-- resultMap 사용으로 unread 해결 --> 
    <select id="read" resultMap="mapping_memberlist">
        SELECT SEQ, NAME, SEX, EMAIL_ADDR, PASSWORD, BIRTH, ADDR, THUMB, PROFILE 
       FROM MEMBER WHERE SEQ = #{seq}
    </select>
    
    <!-- 쿼리 결과에 대한 맵핑 변수명 vs 컬럼명 -->
    <resultMap type="com.sample.mapper.MemberVO" id="mapping_memberlist">
        <result property="seq" column="SEQ"/>
        <result property="name" column="NAME"/>
        <result property="sex" column="SEX"/>
        <result property="email" column="EMAIL_ADDR"/>
        <result property="passWord" column="PASSWORD"/>
        <result property="birth" column="BIRTH"/>
        <result property="add" column="ADDR"/>
        <result property="thumb" column="THUMB"/>
        <result property="profile" column="PROFILE"/>
        <result property="is_delete" column="IS_DELETE"/>
    </resultMap>
</mapper>
 
cs

1) resultMap을 통해 클래스 변수와 DB 컬럼을 하나하나 매칭 시킨다.

 (property는 클래스의 변수명, column은 DB 컬럼명)

2) 매칭 시 부여한 id를 통해 쿼리 결과를 지정하여 준다.

 

5. 적용후

 

 

 

결론적으로 이 방법은 잘 사용하면 유용할 것이다.

실제 변수명이나 클래스 명이 길어지는 것이 부담스러워 일부러 축약시켜 사용하는 경우도 있다.

또한 DB와 코딩을 각각 작업하게 되는 경우 똑같이 작성할 수 없는 경우도 있다.

이럴때 미리 resultMap으로 한번만 정리해 둔다면 유용하게 사용할 수 있을 것이다.

 

 

참고URL

 

[MyBatis] resultMap collection

resultMap에 클래스를 맵핑할때 인자로 다른 클래스가 있을 경우 어떻게 받아올지 찾다가 발견! mybatis에서 테이블간의 1:N관계를 select 할때 resultMap을 통한 일종의 서브쿼리 형식으로 데이터를 가져

ssodang.tistory.com

 

 

728x90
반응형
728x90
반응형

1. build.gradle 에서

1
2
3
4
5
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
cs

apply plugin: 'war'

이 항목이 필요함. 입력 후 저장

 

* 2. Gradle 창에서 리플레시 후 Tasks -> build -> bootWar 더블클릭 (Run창 확인 : Task execution finished 'bootWar'.)

3. FIle -> Project Structure -> Project Settings -> Artifacts -> Gradel : 프로젝트정보~~.war 선택 -> Ok

4. 파일 생성 위치 : build/libs/ *.war

 

 

* 단계에서 생성 되어짐.

728x90
반응형

'코딩 삽질' 카테고리의 다른 글

[jQuery] simple pagination  (0) 2021.04.17
[spring, mybatis] mybatis unread  (0) 2021.04.10
[oracle, mybatis] sequence 사용  (0) 2021.04.10
[jQuery DataTable] row click event  (0) 2021.04.10
[jQuery DataTable] work page reload  (0) 2021.04.10
728x90
반응형

1. oracle에서 시퀀스 추가는 1번만

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- 1. oracle 시퀀스 추가 (COLUMN_SEQ : 시퀀스에 해당되는 컬럼명)
CREATE SEQUENCE COLUMN_SEQ
    MINVALUE 1
    MAXVALUE 9999999999999999999999999999
    INCREMENT BY 1
    START WITH 1
    CACHE 20
    NOORDER
    NOCYCLE ;
 
-- 2. oracle에서 쿼리 사용 시
INSERT INTO TS_BOARD(COLUMN_SEQ,TITLE)
VALUES(COLUMN_SEQ.nextval,'HELLO');
SELECT COLUMN_SEQ.currval FROM dual; 
 -- > INSERT문과 함께 사용할때 최종 사용한 COLUMN_SEQ 값을 확인
 -- > 단독으로 사용시 에러메시지
   -- > ORA-08002: sequence TEST_SEQ.CURRVAL is not yet defined in this session
 
-- 3. oracle에서 단독으로 최종 사용된 시퀀스 값 확인 시
SELECT * FROM user_sequences WHERE sequence_name=upper('COLUMN_SEQ');
cs

 

2. mybatis에서 생성된 시퀀스 사용

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!-- 4. Mybatice에서 쿼리 사용 시 -->
<insert id="insertBoard" parameterType="BoardVO">
    <selectKey keyProperty="columnSeq" resultType="java.lang.Integer" order="BEFORE">
        select COLUMN_SEQ.NEXTVAL from dual
    </selectKey>
    <![CDATA[
        INSERT INTO TS_BOARD
            (
                COLUMN_SEQ
                , TITLE
            )
        VALUES
            (
                #{columnSeq}
                , #{title}
            )
    ]]>
</insert>
cs
728x90
반응형
728x90
반응형
1
2
3
4
$("#table").on('click''tbody tr'function () {
    var row = $("#table").DataTable().row($(this)).data();
    console.log(row);
});
cs

 

 

 

# 관련글

[jQuery DataTable] table paging 적용 : https://deonggi.tistory.com/98

[jQuery DataTable] work page reload : https://deonggi.tistory.com/101

 

 

728x90
반응형
728x90
반응형

의도는 dataTable 사용에서 예를들어 2페이지에서 무언가를 하고 해당 내용을 새로고침 하고 싶은 경우다.

datatables server side processing reload table

Hello! I'm using datatables with server side processing. Need to reload data after changes dynamically. But .reload not working. Console log is clear.

datatables.net

간단히 아래와 같이 사용하면 된다.

1
$('#table').DataTable().ajax.reload( nullfalse );
cs

reload의 괄호내 매개변수를 항목을 지우고 사용하면 첫 페이지가 로딩된다.

 

아래는 해당 함수의 문서

ajax.reload()

ajax.reload() Since: DataTables 1.10 Reload the table data from the Ajax data source. Description In an environment where the data shown in the table can be updated at the server-side, it is often useful to be able to reload the table, showing the latest d

datatables.net

 

 

 

 

# 관련글

[jQuery DataTable] table paging 적용 : https://deonggi.tistory.com/98

[jQuery DataTable] row click event https://deonggi.tistory.com/102

 

 

 

 

728x90
반응형
728x90
반응형

1. ajax으로 json 형태의 데이터를 보낼때 

에러 : org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

javascript 소스의 ajax에 contentType: 'application/json' 추가

 

2. javascript ajax에서 form의 데이터를 json으로 보내야 할때

에러 : org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unrecognized token 'page': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'page': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

 

JavaScript Ajax JSON parse error

Spring Controller와 통신하는 Ajax JSON parse error 고치기!

velog.io

 

jquery form serialize 를 이용하여 json으로 만들기

jquery 에서 form serialize를 이용하여 json 을 만들수 있습니다. 먼저 serialize 에 대해서 간단히 설명하겠습니다. serialize 함수는 2개가 있습니다. 첫번째로 serialize() 입니다. URL-encoded 표기법으로 fo..

cofs.tistory.com

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
 * form 데이터를 json으로 변환
* 사용방법 : JSON.stringify( $("#WRITE_FORM").serializeObject())
 * 출처: https://cofs.tistory.com/184 [CofS]
 */
jQuery.fn.serializeObject = function() {
    var obj = null;
    try {
        if (this[0].tagName && this[0].tagName.toUpperCase() == "FORM") {
            var arr = this.serializeArray();
            if (arr) {
                obj = {};
                jQuery.each(arr, function() {
                    obj[this.name= this.value;
                });
            }//if ( arr ) {
        }
    } catch (e) {
        alert(e.message);
    } finally {
    }
 
    return obj;
};
 
cs

 

3. spring boot에서 리턴 할때 발생한 에러

에러 : HttpMessageNotWritableException: No converter for with preset Content-Type 'null'

 

HttpMessageNotWritableException: No converter for [VO Class] with preset Content-Type 'null'] | ThinkGround

안녕하세요. No converter for [VO Class] with preset Content-Type 'null'] 오류와 관련된 해결 포스트입니다. Spring은 기본적으로 MessageConvertor가 탑재되어 있습니다.

thinkground.studio

위 링크의 정보를 참고해서 리턴 class에 @JsonInclude(JsonInclude.Include.NON_NULL) 를 추가하고 해결됐다.

에러 메시지를 메모해 두기 위해 다시 소스를 원상복구 후 실행 했을때는 에러가 나지는 않았다. ㅡㅡ?? 응??

현재는 위 내용을 제거하고 실행하고 있지만 에러가 없는 상태.

 

 

4. 파일을 전송하기 위한 ajax에서 발생

에러 : java.lang.IllegalStateException: Current request is not of type [org.springframework.web.multipart.MultipartHttpServletRequest]: ServletWebRequest: uri=/bbs/ajax/insert;client=0:0:0:0:0:0:0:1;session=01C5D81F89E59ACA7C2BEE397A35A677

 

ajax 호출을 받는 controller에서 MultipartHttpServletRequest가 누락된 경우 발생한다.

 

728x90
반응형

+ Recent posts