Spring
(Example) 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์ต์ ์ ์ปฌ๋ผ ๋ค์์()์ ์ง์ ํด์ฃผ๊ณ , ํ๋ก๊ทธ๋จ ์์์๋
@Column(name = "service_name")
String serviceName;
reference
java.lang.NullPointerExceptioin
Gradle's dependency cache may be corrupt
compileQuerydsl ์ค๋ฅ
reference
h2 console ์๋ณด์
BaseEntity null๊ฐ ๋ค์ด
์์ธ
JPA Auditing
ํด๊ฒฐ
์๋ ์ฝ๋ ์ถ๊ฐ
@EnableJpaAuditing
reference
Cannot deserialize value of type java.time.LocalDateTime
from String
java.time.LocalDateTime
from StringQuerydsl setting error
๋ฐฐ๊ฒฝ
๊ฒ์ ์ฒ๋ฆฌ๋ฅผ ํตํ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๊ธฐ ์ํด QueryDSL ํ๋ ์์ํฌ ์ ์ฉ
๋ฌธ์
build.gradle์ dependencies์ ์ถ๊ฐํ๊ณ ์คํ์ค
Unable to load class 'com.mysema.codegen.model.Type'
. ๋ธ
์์ธ
QueryDsl์ ๊ธฐ์กด dependency๋ค์ ์ถ๊ฐํ๋ ๊ฒฝ์ฐ์ ๋ค๋ฅด๊ฒ ์ค์ ํ์ผ๋ค์ ์ถ๊ฐํด์ฃผ์ด์ผ ํ์ .. ใ
ํด๊ฒฐ
//build.gradle
// 1) ์ถ๊ฐ
buildscript {
ext {
queryDslVersion = "5.0.0"
}
}
...
// 2) plugin ์ถ๊ฐ
plugins {
id 'org.springframework.boot' version '2.6.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
id 'java'
}
...
// 3) ํ์ผ ์์ฑ ๊ฒฝ๋ก ์ถ๊ฐ
def querydslDir = "$buildDir/generated/querydsl"
querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
configurations {
querydsl.extendsFrom compileClasspath
}
compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
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
Last updated