[Spring Boot]

Disable spring security default login page

문제

spring security 관련 디폴트 로그인 페이지 화면이 계속 뜸

원인

SecurityConfig 클래스가 Configuration으로 등록되지 않아 프로젝트에서 설정 인식을 못함

해결

@Configuration과 @EnableWebSecurity 어노테이션 추가

코드

package net.schoolvery.schoolveryserver.global.security;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .httpBasic().disable()
                .cors().and().csrf().disable();
    }
}

reference

DB 컬럼명에 underbar 있으면 JPA 쿼리 인식 못하는 문제

✔️ 문제

mysql에 맞춰 카멜 케이스로 컬럼명 통일했는데(user_name),

DB 컬럼명에 언더스코어가 있을 경우 findByUser_name(혹은 findByUserName) 못씀

🙇🏻 해결

@Column옵션에 컬럼 네임은()을 지정해주고, 프로그램 안에서는

reference

java.lang.NullPointerExceptioin

Gradle's dependency cache may be corrupt

  • compileQuerydsl 오류

reference

h2 console 안보임

BaseEntity null값 들어

원인

JPA Auditing

해결

아래 코드 추가

reference

Cannot deserialize value of type java.time.LocalDateTime from String

Querydsl setting error

배경

검색 처리를 통한 데이터를 가져오기 위해 QueryDSL 프레임워크 적용

문제

build.gradle의 dependencies에 추가하고 실행중

Unable to load class 'com.mysema.codegen.model.Type'. 뜸

원인

QueryDsl은 기존 dependency들을 추가하는 경우와 다르게 설정파일들을 추가해주어야 했음 .. ㅠ

해결

reference

Querydsl cannot find symbol 에러

문제

Q class 자체가 생성이 안되고, 빌드할 떄 당연히 Q class 참조 못함

원인

JWT util 파일(repository 외의 코드)에서 오류가 생겨 빌드할 때 Q class 생성이 안됨

해결

버그 있는 부분을 해결 하고 다시 빌드하니 Q class 생성 !!!

reference

Table 'DBNAME.TableName' doesn't exist.

ERROR 1074 (42000) at line 3: Column length too big for column 'txt' (max = 21845); use BLOB or TEXT instead

원인

컬럼 value 너무 커서 못들어감

해결

column value 줄여주니까 들어감

reference

Request method 'POST' not supported

[org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]

원인

postman에서 requestbody 보낼때, 처음에 row에서 application type이 text로 되어있었음

해결

json으로 바꿔줌

주의

가끔 postman에서 url 주소랑 메소드 잘못매치해서 404? 뜸 ! ㅋㅋ 주의주의

What is the difference between @Controller and @RestController

Spring에서 컨트롤러를 지정해주기 위한 어노테이션은 @Controller와 @RestController가 있습니다. 전통적인 Spring MVC의 컨트롤러인 @Controller와 Restuful 웹서비스의 컨트롤러인 @RestController의 주요한 차이점은 HTTP Response Body가 생성되는 방식입니다. 이번에는 2가지 어노테이션의 차이와 사용법에 대해 알아보도록 하겠습니다.

@RestController는 @Controller에 @ResponseBody가 추가된 것입니다. 당연하게도 RestController의 주용도는 Json 형태로 객체 데이터를 반환하는 것입니다. 최근에 데이터를 응답으로 제공하는 REST API를 개발할 때 주로 사용하며 객체를 ResponseEntity로 감싸서 반환합니다. 이러한 이유로 동작 과정 역시 @Controller에 @ReponseBody를 붙인 것과 완벽히 동일합니다.

reference

  • 아 이거 pathch-< put?

Cannot determine value type from string

  • db update

reference

Access to DialectResolutionInfo be null when 'hibernate.dialect' not set

reference

java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing

MYSQL)Data too long for column 에러 해결

Last updated