inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

@RequestMapping 질문드립니다.

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

@RequestMapping만 붙인 기존 상태에서 postman으로 같은 url로 GET, POST 요청을 보내도 동일하게 성공하는 것을 확인했습니다. 근데 GET, POST만 되고, PUT, PATCH, DELETE는 안되더라구요. 혹시 GET, POST만 되는 다른 이유가 있을까요? 7:10 부터 관련 내용입니다! (밑에 AI 답변이 있긴하지만, 다른 질문에 대한 답변을 추천해준 것 같습니다)

  • spring
  • mvc
재영 댓글 2 좋아요 0 조회수 489

물리적인 트랜잭션을 처리하는 부분에 대해 헷갈리는 점이 있습니다.

해결됨

스프링 DB 2편 - 데이터 접근 활용 기술

안녕하세요. 항상 강의잘 듣고있습니다! 강의를 완강하고 복기하던 중에 궁금한 점이 있습니다. 강의에서는 커밋 또는 롤백을 하는 경우 트랜잭션 메니저 로 요청을 보내 물리적인 부분을 처리한다 라고 학습했는데요, 가끔씩 강의를 듣다보면 트랜잭션 매니저 -> 트랜잭션 동기화 매니저 를 통해 물리적인 트랜잭션을 처리한다고 말씀하셔서 (스프링 트랜잭션 전파5 - 외부 롤백 6분 20초경) 마지막 물리적으로 처리하는 부분이 트랜잭션 매니저단에서 끝나는지, 트랜잭션 매니저에서 트랜잭션 동기화 매니저를 통해 끝나는지 헷갈려서 질문남깁니다.! 감사합니다!!

  • spring
  • mvc
  • jpa
  • querydsl
  • spring-data-mybatis
  • spring-jpa
JSTS 댓글 2 좋아요 0 조회수 366

@JsonNaming 과 @field:Pattern 이 함께 동작하지 않는 것 같습니다.

미해결

Kotlin으로 개발하는 Spring Boot Web MVC

... @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class UserRequest( ... @field:Pattern(regexp = "^\\\\d{2,3}-\\\\d{3,4}-\\\\d{4}\\\$") var phoneNumber:String?=null, ) 위와 같이 UserRequest 데이터클래스에서 @JsonNaming 과 @field:Pattern 을 동시에 사용하면 @JsonNaming 의 snake case 적용이 작동하지 않아 PUT 요청의 body 에 phoneNumber 로 요청해야만 정상 작동하고 phone_number 로 요청하면 400 에러가 나지만, 해당 필드에 @field:Pattern 대신 @field:Size 를 사용하면 @JsonNaming 에 기대하는대로 phone_number 로 요청해도 200 응답으로 정상작동 하는 현상을 겪고 있습니다. 왜 Validation 어노테이션을 바꾸었을 뿐인데 그와 상관없어보이는 @JsonNaming 의 작동 여부에 영향을 끼치는지 궁금합니다.

  • mvc
  • rest-api
  • spring-boot
  • junit
hmp0077 댓글 1 좋아요 0 조회수 321

th:class 부분 th:if /th: classappend

미해결

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

위 코드에서 th: class= ${errors?.containsKey('itemName')} ? ~~~ 를 if 조건식으로 참 거짓 구분하여 참이면 클래스 뒤에 append를 해주는 방식으로 해주었는데 이방식으로 하면 아예 상품명 공간이 사라지네요 ㅜ 다른방식으로도 해보고 싶은데 강사님이 알려주신 th:class 밖에 없는것일까요? 타임리프 기본 문법을 다시 보면서 변형해보고있는데 잘 안되서요 😅 th:if="${errors?.containsKey('itemName')}" th:classappend="field error"

  • spring
  • mvc
댓글 1 좋아요 0 조회수 520

강의 자료 오타 제보합니다.

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

[질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 예 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) 예 [질문 내용] 3. 회원 관리 예제 - 백엔드 개발.pdf 5번째 페이지 MemoryMemberRepositoryTest 클래스의 save() 메서드 부분이 이렇게 되어 있습니다. 마지막 줄이 수정이 필요해 보입니다. @Test public void save() { //given Member member = new Member(); member.setName("spring"); //when repository.save(member); //then Member result = repository.findById(member.getId()).get(); (result).isEqualTo(member); }

  • java
  • spring
  • mvc
  • spring-boot
qdlsungls 댓글 1 좋아요 0 조회수 249

Spring Security 의 ProviderManager (AuthenticationManager) 도 옵저버 패턴을 사용하고 있다고 볼 수 있을까요?

미해결

코딩으로 학습하는 GoF의 디자인 패턴

안녕하세요 강사님! 우선 양질의 강의 잘 듣고 있다는 말씀 드리고 싶습니다. Spring Security 에서 AuthenticationProvider 를 찾아서 인증을 위임하는 역할을 수행하는 ProviderManger 도 옵저버 패턴을 사용하고있다고 볼 수 있을까요? ProviderManager (AuthenticationManager) 에서 AuthenticationProvider 들을 가져온후 이들을 순회하며 인증위임을 시키는 코드입니다 단순히 supports() 를 통해 인증을 위임시킬 AuthenticationProvider 들을 골라내는 것뿐, 이것도 옵저버 패턴이 적용된 예인지 알고 싶습니다.

  • java
  • 디자인-패턴
PrivilegeEscalate 댓글 2 좋아요 0 조회수 422

윈도우 gradlew.bat build 에러 발생

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

C:\Users\Yoon>cd C:\Users\Yoon\Desktop\CS\SpringStudy\hello-spring C:\Users\Yoon\Desktop\CS\SpringStudy\hello-spring>gradlew.bat build FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'hello-spring'. > Could not resolve all files for configuration ':classpath'. > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.1. Required by: project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.1 > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.1 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.5' but: - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.2.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.2.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.1 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.5') * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 5s "빌드하고 실행하기" 강의에서 위 에러가 발생하였습니다. 우선 저는 윈도우 사용자입니다. java --version으로 확인해봐도 Java 17버전이고, 설정 가능한 모든 부분에서 17버전으로 바꿨는데도 에러가 발생합니다. 파일 링크 : https://drive.google.com/file/d/1hnY1DJJ-9loR_mcQBum97NDgOErGgoMO/view?usp=drive_link

  • java
  • spring
  • mvc
  • spring-boot
댓글 2 좋아요 0 조회수 806

질문있습니다

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예 3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예 [질문 내용] 안녕하세요 오늘도 어김없이 강의구매후 잘보고있습니다 ㅎ다름이 아니라 강의를 아직 보고있는데 궁금한게 생겨서요ㅎㅎ 스프링부트 내장 톰캣 을 사용하고 정적 , 동적 파일이 있잖아요 중 정적파일 처리 과정이 궁금해서Ex) 스프링부트에 내장 톰캣에 타임리프 사용시 localhost/index.html 을 호출하면 html의 경우 정적파일인데 jsp처럼 html 정적파일도 뮤조건 톰캣 서블릿을 타서 스프링에서 뷰리졸브(view)를 통해 응답을 해주는걸까요 아니면 톰캣에서 정적파일이내 를 분류해서 바로 뿌려주게되나요 ?? 이게궁금해서요

  • spring
  • mvc
넌멋지다 댓글 2 좋아요 0 조회수 267

h2db에 입력후 localhost 조회시 안나옴

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

https://drive.google.com/file/d/1bWQeZq1FfiqL2cIEU7zJu-_Td0NSqGwF/view?usp=drive_link

  • java
  • spring
  • mvc
  • spring-boot
ja04261 댓글 2 좋아요 0 조회수 295

Q파일 생성 위치 질문

해결됨

실전! Querydsl

안녕하세요 현재 프로젝트 세팅 및 테스트를 진행 중입니다. spring boot가 3이상으로 제한된 상황속에서 진행중이며, 강의 내용을 따라하고 있습니다! build.gradle은 https://docs.google.com/document/d/1j0jcJ9EoXMGzwAA2H0b9TOvRtpwlxI5Dtn3sRtuXQas/edit#heading=h.vfy9wirpglmx 를 복/붙 하였습니다. plugins { id 'java' id 'org.springframework.boot' version '3.2.0' id 'io.spring.dependency-management' version '1.1.4' } group = 'study' version = '0.0.1-SNAPSHOT' sourceCompatibility = '17' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' //test 롬복 사용 testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' //Querydsl 추가 implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api" } tasks.named('test') { useJUnitPlatform() } clean { delete file('src/main/generated') } 질문은 크게 3가지입니다. build/other/compileQuerydsl은 표기가 안되는데 다른 답변을 보니 springboot3으로 올라가며 compileQuerydsl은 표기가 안된다고 하신 것 같은데 맞을까요? 정확한 Q파일의 생성 위치가 궁굼합니다.! 강의상에서는 src/main에 둬도 괜찮지만, 버전관리 시스템(git)에는 추가 되지 않는게 좋다고 하셨던 것 같은데 맞나요? build에만 Q파일이 생성되는게 좋나요? 올려주신 google doc의 build.gradle로 진행하면, Q파일이 build/annotationProcessor아래 생성됩다... 뭐가 문제일까요? docs에 올려주신 build.gradle에서 build clean을 진행할 때 'src/main/generated'의 폴더를 삭제하는 이유가 무엇일까요? (현재 저는 Q파일을 build/ 아래 관리하고있는데, src/main/generate 아래 Q파일을 생성하시는 분들에만 해당 되는 내용인가요?) 답변해주시면 감사하겠습니다!

  • java
  • jpa
김주영 댓글 2 좋아요 1 조회수 879

엔티티 변경 후 일대다

해결됨

자바 ORM 표준 JPA 프로그래밍 - 기본편

@JoinColumn(name = "MEMBER_ID) List<AddressEntity> addressHistory = .. 다대일이 아닌 일대다로 매핑한 이유가 있을까요? 앞에서 다쪽에 @JoinColumn하는 것을 추천하셨는데 일쪽에 연관관계 주인을 잡은 이유가 궁금합니다.

  • java
  • jpa
모깅 댓글 2 좋아요 0 조회수 349

@Controller 질문있습니다.

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

@Controller가 붙으면 로직을 수행하는 컨트롤러가 되고 이 컨트롤러에서 수행되는 로직은 요청과 동일한 @RequestMapping이 붙은 메소드가 실행된다 라고 생각하면 되는건가요? @Controller가 붙은 클래스가 컨트롤러가되서 HandlerMapping에 등록된 후 내부적으로 @RequestMapping으로 구분을 하는건지 아니면 각각의 메소드가 컨트롤러가 되서 HandlerMapping에 등록되는건지 궁금합니다.

  • spring
  • mvc
김민재 댓글 2 좋아요 0 조회수 322

http://localhost:8080/ 접속 웹페이지 오류

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 강의를 따라서 코드를 작성했습니다. http://localhost:8080/ 으로 접속하면 home.html 이 아니라 static 폴더의 index.html 이 열립니다. 어떻게 해결하면 될까요?

  • java
  • spring
  • mvc
  • spring-boot
박보배 댓글 3 좋아요 0 조회수 657

기본 디렉토리 구조 설정이 궁금해요

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예 3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예 [질문 내용] localhost:8080/jsp/members/new-form.jsp 경로에서 webapp 밑에 있다는건 어디서 알 수 있는 정보인지 궁금합니다.또한, 그 설정을 개인적으로 설정할 수 있다면 그 방법이 궁금합니다

  • spring
  • mvc
mrx 댓글 1 좋아요 0 조회수 387

생각한대로 실행이 되지 않습니다.

미해결

자바 ORM 표준 JPA 프로그래밍 - 기본편

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요. 제 프로젝트 압축파일입니다. https://drive.google.com/file/d/1CsFmsNczcupxGIQTMM_-uA7EQFzu3KRq/view?usp=sharing JpaMain에서 Movie movie = new Movie(); movie.setDirector("aaa"); movie.setActor("asdf"); movie.setName("바람과 함께 사라지다"); movie.setPrice(10000); em.persist(movie); em.flush(); em.clear(); 에 의해 movie가 insert되어야하는데 실제로 데이터베이스의 MOVIE테이블을 조회해보면 아무것도 없습니다. 그리고 아래와 같은 에러로그가 뜨는데 어떻게 해야할지 모르겠어서 질문드립니다! https://drive.google.com/file/d/1YCpr2ZBFSC84lw3wvn5wks22DVx1GHAM/view?usp=sharing

  • java
  • jpa
966kmj 댓글 3 좋아요 0 조회수 453

@CookieValue Long memberId

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) Long type 자동 변환된 memberId를 memberRepository.findById(memberId) 하니 Integer 이하 생략 그림참조 에러떠서 진행이 안됩니다.

  • spring
  • mvc
모네 댓글 2 좋아요 1 조회수 446

하이버네이트 빈 밸리데이션 언어 관련 질문

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

@NotEmpty 어노테이션 사용하면 기본메세지가 한국어로 되어있던데 이게 어떤 걸 영향받아서 한국어로 기본메세지를 출력하는 것인지 궁금합니다. 영어로 설정하면 영어가 나올까 싶어서 구글 브라우저 언어순위에 영어를 상단으로 올려보고, 크롬 언어자체를 영어로 바꿔봐도 한국어로 비어 있을 수 없습니다 라고 출력이되는데 이 어노테이션이 어디에 영향을 받아서 한국어로 출력하는 것인지 궁금합니다. 따로 errors.properties 에 설정되어있지도 않아서 더 궁금합니다. ++ @NotEmpty 어노테이션 타고들어가니까 기본메세지가 여러가지 언어로 국제화되어있었어요 이상해서 다시 크롬 언어설정에서 영어 최상단하고 해보니까 영어로바뀌네요 아까는 안되었는데 왜 지금은 되는건지 의문;;

  • spring
  • mvc
한현진 댓글 2 좋아요 0 조회수 293

사소하지만 다음과 같이 되는게 맞을까요?

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

예외를 통해 에러코드 500이 만들어 진것을 수정하여 400으로 고치는 로직이므로 error/400페이지를 보여주는게 맞는 흐름일 것 같은데 아닐까요? // TEXT/HTML return new ModelAndView("error/400");

  • spring
  • mvc
김허수 댓글 2 좋아요 0 조회수 441

Model객체가 url에 쿼리스트링으로 보여지는게 아니였나요?

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

이 매핑 컨트롤러 테스트 할때 url에 localhost:8080/ ..?param1=data1&param2=data2 이렇게 나올 줄 알았는데 쿼리스트링엔 생략되서 나오더라고요?.. 그래서 아래와 같이 테스트하니 url에 파라미터 가 추가 되는걸 확인할 수 있었습니다. 원래 Model 객체는 url에 쿼리스트링 추가해주는것이 아니였나요? 지금까지 그렇게 알고 있었는데 막상 테스트해보니 RedirectAttributes객체만 되는것 같네요

  • spring
  • mvc
Won Ders 댓글 2 좋아요 1 조회수 424

스프링 시큐리티 질문

미해결

스프링 프레임워크는 내 손에 [스프2탄]

package kr.bit.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; 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.crypto.factory.PasswordEncoderFactories; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; @Configuration //스프링 컨테이너 설정파일이라고 메모리에 올림 @EnableWebSecurity public class SecurityConfiguration { @Autowired private UserDetailsServiceImpl userDetailsService; //패스워드 인코딩 객체를 스프링 컨테이너에 등록 @Bean public PasswordEncoder PasswordEncoder() { return PasswordEncoderFactories.createDelegatingPasswordEncoder(); } @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http.csrf(csrfConfig -> csrfConfig.disable() ) .authorizeHttpRequests(authorizeRequests -> authorizeRequests .anyRequest().permitAll() ) .formLogin(login -> login .loginPage("/member/login") .defaultSuccessUrl("/board/list") ) .logout(logout -> logout .logoutUrl("/member/logout") .logoutSuccessUrl("/") ) .userDetailsService(userDetailsService); return http.build(); } } 모든 접근에 대해 permitAll()을 하면 http://localhost:8080/m15/ http://localhost:8080/m15/member/login 둘다 잘 접속 되지만 package kr.bit.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; 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.crypto.factory.PasswordEncoderFactories; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; @Configuration //스프링 컨테이너 설정파일이라고 메모리에 올림 @EnableWebSecurity public class SecurityConfiguration { @Autowired private UserDetailsServiceImpl userDetailsService; //패스워드 인코딩 객체를 스프링 컨테이너에 등록 @Bean public PasswordEncoder PasswordEncoder() { return PasswordEncoderFactories.createDelegatingPasswordEncoder(); } @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http.csrf(csrfConfig -> csrfConfig.disable() ) .authorizeHttpRequests(authorizeRequests -> authorizeRequests .requestMatchers("/", "/member/**").permitAll() .requestMatchers("/board/**").authenticated() ) .formLogin(login -> login .loginPage("/member/login") .defaultSuccessUrl("/board/list") ) .logout(logout -> logout .logoutUrl("/member/logout") .logoutSuccessUrl("/") ) .userDetailsService(userDetailsService); return http.build(); } } requestMatchers 로 permitAll()하면 http://localhost:8080/m15/ 로 접속하면 http://localhost:8080/m15/member/login 로 이동하면서 에러가 발생합니다. 스프링 부트 버전은 3.2.1입니다.

  • spring
  • jquery
  • mvc
  • jpa
  • spring-security
휴식중인너구리 댓글 1 좋아요 0 조회수 1041

인기 태그

인프런 TOP Writers

주간 인기글